Winform学习(4)--关于文件的读取

对文件进行数据输入
需要用到using system.IO;
String path=”//文件路径”;
StreamWrier a=new StreamWriter(path,true);
a. WriteLine(“//输出的字符”);
a. close(); //关闭文件
a. dispose(); //释放内存
对文件进行数据读取
需要用到using system.IO;
String Path=”//文件路径”;
String Dialogue;
StreamWriter b=new StreamWriter(Path);
Dialogue=b.ReadtoEnd();
PS: 对文件读取时,若无true ,则程序打开文件时,若文件不存在则创建文件(有没有true都会这样),若存在,则覆盖文件。

猜你喜欢

转载自blog.csdn.net/weixin_42132384/article/details/81478148