How to add lines of a text file into individual items on a ListBox (C#)

前端 未结 4 1890
渐次进展
渐次进展 2021-01-23 00:52

How would it be possible to read a text file with several lines, and then to put each line in the text file on a separate row in a ListBox?

The code I have so far:

4条回答
  •  礼貌的吻别
    2021-01-23 01:18

    string[] lines = System.IO.File.ReadAllLines(@"ignore.txt");
    
    foreach (string line in lines)
    {
        listBox.Items.Add(line);
    }
    

提交回复
热议问题