c#读写txt

附加到txt:StreamWriter sw =System.IO.File.AppendText(path); //绝对路径 sw.Write("写入内容");

写入到txt: StreamWriter sw2 =new StreamWriter(path); //绝对路径 sw.Write("写入内容");

最后都要 sw.Close();

读取txt:StreamReader sr = new StreamReader(path); //绝对路径   string line=""; while((line=sr.ReadLine())!=null){//操作行}  最后关闭流 sr.Close();