附加到文本文件的一部分 [英] Append to Part of Text File

查看:67
本文介绍了附加到文本文件的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Streamwriter创建了一个数据文本文件,该文件以文本的结尾行结尾.如何删除文本的终止行并追加到该文件,然后在新附加部分的末尾添加文本的终止行?

谢谢
Paul Bayley

I''ve created a data text file with Streamwriter which ends with a terminator line of text. How do I remove the terminator line of text and append to that file then adding the terminator line of text at the end of the new appended section?

Thanks
Paul Bayley

推荐答案

*将文件读入stringbuilder对象.
*找到,然后删除终止符行.
*附加文字.
*附加终止符行.
*再次保存到txt文件(覆盖现有文件).

希望这会有所帮助.
* read the file into a stringbuilder object.
* find, then remove the terminator line.
* append text.
* append terminator line.
* save again to txt file (overwrite the existing file).

Hope this helps.


这篇关于附加到文本文件的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆