其他分享
首页 > 其他分享> > WPF 读写文件

WPF 读写文件

作者:互联网

1.读文件

1 StreamReader sr = new StreamReader(@"D:\JointIn.txt");
2 string sLine = "";
3 while(!sr.EndOfStream)
4 {
5        sLine += sr.ReadLine();
6 }
7 Console.WriteLine(sLine); 
8 sr.Close(); 

2.写文件

1 StreamWriter sw = new StreamWriter(@"D:\JointOut.txt");
2 sw.WriteLine("Hello World");
3 sw.Flush();
4 sw.Close();

 

标签:文件,sLine,sr,读写,sw,WriteLine,WPF,txt,StreamReader
来源: https://www.cnblogs.com/LXLR/p/16672981.html