如何在不覆盖当前数据的情况下将数据写入文本文件 [英] How to write data to a text file without overwriting the current data
本文介绍了如何在不覆盖当前数据的情况下将数据写入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎无法弄清楚如何在不覆盖数据的情况下将数据写入文件.我知道我可以使用File.appendtext,但不确定如何将其插入我的语法中.这是我的代码:
I can't seem to figure out how to write data to a file without overwriting it. I know I can use File.appendtext but I am not sure how to plug that into my syntax. Here is my code:
TextWriter tsw = new StreamWriter(@"C:\Hello.txt");
//Writing text to the file.
tsw.WriteLine("Hello");
//Close the file.
tsw.Close();
我希望它在每次运行程序时都写入Hello,而不是覆盖以前的文本文件.感谢您阅读本文.
I want it to write Hello every time I run the program, not overwrite the previous text file. Thanks for reading this.
推荐答案
通过 这篇关于如何在不覆盖当前数据的情况下将数据写入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!true
查看全文