
代碼
using System.IO;
//寫入
StreamWriter sw = new StreamWriter( @"C:\temp123.txt");
sw.WriteLine("----------------hello----------------");
sw.WriteLine("内容");
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 就是 後邊的資料覆寫前邊的