Answers for "add text file to listbox c#"

C#
0

add text file to listbox c#

OpenFileDialog f = new OpenFileDialog();
    if (f.ShowDialog() ==DialogResult.OK)
    {
        listBox1.Items.Clear();

        List<string> lines = new List<string>();
        using (StreamReader r = new StreamReader(f.OpenFile()))
        {
            string line;
            while ((line = r.ReadLine()) != null)
            {
                listBox1.Items.Add(line);

            }
        }
    }
Posted by: Guest on November-07-2020

C# Answers by Framework

Browse Popular Code Answers by Language