我想要实现的是将文本文件加载到列表框中.看起来很简单,但是当有新行时我需要在文本文件中识别,并且每个新行都需要是列表框中的一个新项目.
What I am wanting to achieve is loading a text file into a listbox. It seems simple enough but I need to recognise in the text file when there is a new line, and each new line needs to be a new item in the listbox.
如果可以的话,我们将不胜感激.
If this is possible, a reply would be much appreciated.
这样就可以了
List<string> lines = new List<string>();
using (StreamReader r = new StreamReader(f))
{
string line;
while ((line = r.ReadLine()) != null)
{
lines.Add(line);
}
}
这篇关于将文本文件加载到列表框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!