简体   繁体   English

如何将RichTextBox文本保存到文本资源文件?

[英]How to save RichTextBox text to a text resource file?

I have created a text file named 'Notes' in the resources of my project and want to load/save the text of a RichTextBox to it. 我在项目资源中创建了一个名为“ Notes”的文本文件,并希望将RichTextBox的文本加载/保存到该文件。 I tried using MyProject.My.Resources.Notes in the path. 我尝试在路径中使用MyProject.My.Resources.Notes It doesn't show any error in the code window but when I run it, it shows an error. 它在代码窗口中没有显示任何错误,但是当我运行它时,它显示了一个错误。

Here's what I'm using to load the text: 这是我用来加载文本的内容:

RichTextBox1.Text = System.IO.File.ReadAllText(MyProject.My.Resources.Notes) 

Here's what I'm using for saving it: 这是我用来保存的内容:

System.IO.File.WriteAllText(MyProject.My.Resources.Notes, RichTextBox1.Text) 

This is not a duplicate. 这不是重复项。 I did not get an answer from the other question 我没有从另一个问题得到答案

Why don't you use a regular file which always works fine or a database? 为什么不使用可以正常工作的常规文件或数据库?

Edit: maybe this helps? 编辑:也许这有帮助吗? www.dondraper.com/2011/01/easily-save-and-retrieve-application-and-user-settings-in-vb-net-or-c-apps/ www.dondraper.com/2011/01/easily-save-and-retrieve-application-and-user-settings-in-vb-net-or-c-apps/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM