码迷,mamicode.com
首页 > 其他好文 > 详细

Resolve StreamReader ReadLine left the first character

时间:2020-06-04 13:54:35      阅读:54      评论:0      收藏:0      [点我收藏+]

标签:rac   space   pac   OLE   dem   add   string   tostring   time   

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

标签:rac   space   pac   OLE   dem   add   string   tostring   time   

原文地址:https://www.cnblogs.com/Fred1987/p/13042679.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!