C#将数据写入记事本并且从记事本中读出

代码
using System.IO;

//写入
StreamWriter sw = new StreamWriter( @"C:\temp123.txt");
sw.WriteLine(
"----------------hello----------------");
sw.WriteLine(
"内容");
sw.WriteLine(
"----------------hello----------------");
sw.Flush();
sw.Close();

//读取
System.IO.StreamReader st;
st 
= new System.IO.StreamReader(@"C:\temp123.txt", System.Text.Encoding.UTF8);//UTF8为编码
this.textBox1.Text = st.ReadToEnd();

StreamWriter sw = new StreamWriter( @"C:\temp123.txt",true);
后边参数为true就是 有新数据继续写
要是为false 就是 后边的数据覆盖前边的

原文地址:https://www.cnblogs.com/hantianwei/p/1933101.html