附加到txt:StreamWrite sw =System.IO.File.AppendText(path); //绝对路径 sw.Write("写入内容");
写入到txt: StreamWrite sw2 =new StreamWrite(); sw.Write("写入内容");
最后都要 sw.Close();
读取txt:StreamReader sr = new StreamReader(path); //绝对路径 string line=""; while((line=sr.ReadLine())!=null){//操作行} 最后关闭流 sw.Close();
时间: 2024-11-25 14:42:03