我正在寻找一种可以读取文本文件的方法,一次一个单词,直到文件结束。这是我目前的代码,但它只从文件中读取一个单词,没有更多。如何处理整个文件?
var ResourceStream = Application.GetResourceStream(new Uri("test.txt",UriKind.Relative));
using (Stream myFileStream = ResourceStream.Stream)
{
string s = "";
StreamReader myStreamReader = new StreamReader(myFileStream);
s = myStreamReader.ReadToEnd();
s = s.Trim();
//tlbwords.Text = s;
char[] delimiters = { '\n', '\r' };
string[] words = s.Split(delimiters);
tlbwords.Text = words[0];
}
}
}
}