将RichTextBox文本写入File [英] Write RichTextBox text to File

查看:60
本文介绍了将RichTextBox文本写入File的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用文件流从Richtextbox写入文件。它工作正常,但新行在保存的文件中不起作用。

I tried using file stream to write to File from Richtextbox. it works okay but the new lines are not working in the saved file.

推荐答案

富文本框不像文本文件那样使用换行符:他们处理信息的段落,这些信息在很大程度上基于盒子的大小而不是它们包含的文本分成新的行。这并不会转化为文本友好信息,因为如果确实如此,当您重新加载RTB时,如果RTB大小发生变化,那么行将固定并出错。



将其另存为富文本,任何富文本编辑器(例如Word)都应该能够读取它并对其进行精心分页。文本文件不适用于此!
Rich text boxes don't use newlines in the same way that "text files" do: they work on "paragraphs" of information which split into new lines based largely on the size of the box, not the text they contain. This doesn't translate into "text friendly" information because if it did, when you reloaded the RTB the lines would be "fixed" and wrong if the RTB size changed.

Save it as Rich Text, and any Rich Text editor (Word for example) should be able to read it and paginate it nicely. Text files aren't meant for that!


尝试任何文本编辑器,例如notepad ++,除记事本外的wordpad我相信你会看到那些新行。我认为Environment.NewLine可以处理这个。
Try any text editor e.g. notepad++ , wordpad except notepad I am sure you will see those new line.I think Environment.NewLine can handle this.


这篇关于将RichTextBox文本写入File的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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