Resolve StreamReader ReadLine left the first character
Posted fred1987
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Resolve StreamReader ReadLine left the first character相关的知识,希望对你有一定的参考价值。
static void FileStreamWriterReadDemo() { string textFile = "fs.txt"; using (FileStream fs = new FileStream(textFile, FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs)) { for (int i = 0; i < 100; i++) { string msg = $"Time:{DateTime.Now.ToString("yyyyMMddHHmmssffff")},Guid:{Guid.NewGuid()}"; sw.WriteLine(msg); Thread.Sleep(1); } } } using (StreamReader reader = new StreamReader(textFile)) { string result; while (!string.IsNullOrWhiteSpace(result = reader.ReadLine())) { Console.WriteLine(result); } } }
The key located at.
string result; while (!string.IsNullOrWhiteSpace(result = reader.ReadLine())) { Console.WriteLine(result); }
以上是关于Resolve StreamReader ReadLine left the first character的主要内容,如果未能解决你的问题,请参考以下文章
StreamReader.Read 和 StreamReader.ReadBlock 之间的区别