![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
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");
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 就是 后边的数据覆盖前边的