//StreamRead来读取一个文件
using (StreamReader sr = new StreamReader(@"C:\Users\enle\Desktop\新建文本文档.txt", Encoding.Default))
{
while (!sr.EndOfStream)//循环的去读文件
{
Console.WriteLine(sr.ReadLine());
}
}
Console.ReadKey();
StreamWriter写入一个文本文件
//StreamWriter写入一个文本文件
using (StreamWriter strw = new StreamWriter(@"C:\Users\wbrm\Desktop\新建.txt",true ))//true 表示追加
{
//strw.Write("别再能吃苦的年纪选择安逸");
strw.Write("看我有某有把你覆盖掉");
}
Console.WriteLine("写入成功");
Console.ReadKey();