c#读写txt文件

//表示清空 txt
StreamWriter sw = new StreamWriter("D:\\1.txt");
string w = "";
sw.Write(w);
sw.Close();
//表示向txt写入文本
StreamWriter sw = new StreamWriter("D:\\1.txt");
string w = "10";
sw.Write(w);
sw.Close();
//表示追加文本
StreamWriter sw =File.AppendText("D:\\1.txt");
string w = "2";
sw.Write(w);
       //sw.WriteLine(w);
       sw.Close();

c#读写txt文件

上一篇:浅谈C#中的接口和抽象类


下一篇:win7 开启休眠