可能重复:
How to read a text file reversely with iterator in C#如何读取最后一行在C#中的文本文件,第一行
我想知道如何从最后一行到第一读取文本文件行在C#中。
我使用这个代码读取文本文件
using (var sr = File.OpenText("C:\\test.txt"))
{
string line;
bool flag = true;
while ((line = sr.ReadLine()) != null)
{
}
}
我不知道如何倒读。
如果有人能帮助我,我会非常感激。
在此先感谢。
做检查http://stackoverflow.com/questions/452902/how-to-read-a-text-file-reversely-with -iterator-in-c-sharp,它特别提到不会将整个文件读入内存中,至此发布的答案似乎在做。 –