实现一个 TextReader,使其以一种特定的编码从字节流中读取字符。
关注公众号霸道的程序猿获取编程相关电子书、教程推送与免费下载。
大量编程视频教程:https://space.bilibili.com/164396311
新建命令窗口程序。
在main方法中:
//使用StramReader来读取一个文本文件 using (StreamReader sr = new StreamReader(@"C:\Users\Administrator\Desktop\badao.txt",Encoding.Default)) { while (!sr.EndOfStream) { Console.WriteLine(sr.ReadLine()); } } Console.ReadKey();
在上面的代码中读取了指定文件路径和指定了编码格式的文本文件。
转载于:https://www.cnblogs.com/badaoliumangqizhi/p/11456103.html