如何覆盖txt文件中的数据?
我有 WPF C# 应用程序,它读取和写入 .txt 文件,我知道如何写行但行,但如何覆盖文本那已经是 文件。这就是我要写入文本文件的下一行的内容,但我想越过这些行而不仅仅是写入下一行,谢谢。
using (StreamWriter newTask = new StreamWriter("test.txt", true))
{
newTask.WriteLine(name[i].ToString());
}
Possible Duplicate:
Can any one tell why the previous data is still displayed while saving data using StreamWriter
I have WPF C# application, that reads and writes to a .txt file, i know how to write line but line, but how do I overwrite the text that is already the file. This is what I have just to write to the next line of the text file, but I want to over the lines not just write to the next line, thanks.
using (StreamWriter newTask = new StreamWriter("test.txt", true))
{
newTask.WriteLine(name[i].ToString());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将第二个参数更改为 false:
You need to change the second parameter to false:
您将
true
作为append
参数传递。You're passing
true
as theappend
parameter.