c#读写txt
附加到txt:StreamWriter sw =System.IO.File.AppendText(path); //絕對路徑 sw.Write("寫入內(nèi)容");
寫入到txt: StreamWriter sw2 =new StreamWriter(path);?//絕對路徑?sw.Write("寫入內(nèi)容");
最后都要 sw.Close();
讀取txt:StreamReader sr = new StreamReader(path); //絕對路徑 ? string line=""; while((line=sr.ReadLine())!=null){//操作行} ?最后關(guān)閉流 sr.Close();
?
轉(zhuǎn)載于:https://www.cnblogs.com/heifengwll/p/4058938.html
與50位技術(shù)專家面對面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
- 上一篇: 实现Operations Manager
- 下一篇: C# 跨程序集调用常量、变量和函数