我想要实现的是将文本文件加载到列表框中。这看起来很简单,但是当有新行时我需要在文本文件中识别,并且每个新行都需要是列表框中的新项目。
如果可能的话,将不胜感激。
最佳答案
这会起作用
List<string> lines = new List<string>();
using (StreamReader r = new StreamReader(f))
{
string line;
while ((line = r.ReadLine()) != null)
{
lines.Add(line);
}
}
关于c# - 将文本文件加载到列表框中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9531375/