Tag: 文本文件

什么是逐行读取文本文件的最快方法?

我想逐行阅读一个文本文件。 我想知道如果我在.NET C#范围内尽可能有效地做到这一点。 这是我到目前为止的尝试: var filestream = new System.IO.FileStream(textFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite); var file = new System.IO.StreamReader(filestream, System.Text.Encoding.UTF8, true, 128); while ((lineOfText = file.ReadLine()) != null) { //Do something with the lineOfText }