問候,我似乎無法弄清楚如何在不覆蓋文件的情況下將數據寫入文件。我知道我可以使用File.appendtext,但我不確定如何將其插入到我的語法中。這裏是我的代碼:如何在C#中將數據寫入文本文件而不覆蓋當前數據
TextWriter tsw = new StreamWriter(@"C:\Hello.txt");
//Writing text to the file.
tsw.WriteLine("Hello");
//Close the file.
tsw.Close();
我希望它每次運行程序時寫你好,不覆蓋以前的文本文件。感謝您閱讀本文。
這裏的@是什麼意思?謝謝 – user2420472 2014-01-31 16:46:12