对于小文本文件,最简单的解决方案是重写整个文件。这并不意味着删除文件和然后创建一个新的,但它意味着使用''FileStream.SetLength''将文件的长度设置为0然后使用''System.IO.StreamWriter将数据写入文件''。 For small text files, the simplest solution is to rewrite the whole file. This doesn''t mean deleting the file and then creating a new one, but it means setting the file''s length to 0 using ''FileStream.SetLength'' and then write the data to the file using ''System.IO.StreamWriter''. 这取决于文件的大小和更新之间的间隔。 - MS Herfried K. Wagner MVP< URL:http://dotnet.mvps.org/> VB < URL:http://dotnet.mvps.org/dotnet/faqs/> This depends on the size of the file and the intervalls between the updates. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> 我认为一切< 10 KB一个小文件,但那只是我个人的 意见。 - MS Herfried K. Wagner MVP< URL:http://dotnet.mvps.org/> VB< URL:http://dotnet.mvps。 org / dotnet / faqs />I consider everything < 10 KB a "small file", but that''s only my personalopinion.--M S Herfried K. WagnerM V P <URL:http://dotnet.mvps.org/>V B <URL:http://dotnet.mvps.org/dotnet/faqs/> 这篇关于编辑文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-03 18:27