在 Visual C# 中从 RichTextBox 中删除 RichText 格式
我正在用 C# 开发一个高级富文本编辑器,但偶然发现了一个我似乎无法理解的问题。
我一直试图让用户将他们的文档保存为文本文件(纯文本)。 通过使用以下内容:
MyRichTextBox.SaveFile(filepath, PlainText);
但问题是,当他们在记事本中查看该文件(应该保存为纯文本)时,它会显示所有 RTF 格式代码,这使得他们的文档无法读取。 有谁知道任何其他方法可以从 RichTextBox 中删除格式代码而不必做太多事情?
我的意思是,如果要找到解决如此简单任务的方法需要大量工作,我不妨从头开始创建自己的 RichTextBox 控件。 我确信这很难做到,但至少我知道它会起作用……
抱歉在这里咆哮了一点,呵呵……
谢谢大家, 杰森.
I'm developing an advanced rich text editor in c# but have stumbled upon a problem that I can't seem to grasp.
I have been trying to let users save their documents as Text files (plain text). By using the following:
MyRichTextBox.SaveFile(filepath, PlainText);
But the problem is that when they view that file (which should have been saved as plain text) in Notepad, it shows up with all of the RTF formatting codes whish makes their documents unreadable. Does anybody know of any other way to remove formatting codes from a RichTextBox without having to do too much?
I mean, if there's going to be alot of work involved in finding a workaround to such a simple task, I might as well just create my own RichTextBox control from scratch. Which I'm sure would be very hard to do, but atleast I know that it'll work...
... Sorry for ranting on a little there, hehe...
Thanks All,
Jason.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可以做到:
或者,获取 RTF 的方法是:
This should do it:
Alternatively, the way to get the RTF is:
您是否尝试过:
而不是:
Have you tried:
instead of: