1

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. I tried using MyProject.My.Resources.Notes in the path. 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

Aman
  • 59
  • 2
  • 12
  • Whilst saving i get these: `FileNotFoundException was unhandled` and `A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll` – Aman Feb 13 '16 at 07:46
  • 1
    Possible duplicate of [How to write to a text file inside of the application](http://stackoverflow.com/questions/15487006/how-to-write-to-a-text-file-inside-of-the-application) – Andrew Morton Feb 13 '16 at 11:17
  • If you have added a text file called "Notes" to your project's Resources (using the Resources tab of the project's properties page), you can read it like this `Dim myNotes As String = My.Resources.Notes`. However, you can't write to the resource. If you want to update it, you can write it somewhere else, or use `My.Settings` instead. – Blackwood Feb 13 '16 at 14:05
  • Is there any other way to store text inside the application itself without using `My.Settings` as they are notes and could be multi-lined. – Aman Feb 14 '16 at 16:29
  • Application resources are not a database. So, no, you can't write to it at runtime. – LarsTech Feb 16 '16 at 16:15

1 Answers1

0

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/

xmorera
  • 1,933
  • 3
  • 20
  • 35
  • I've never used databases so i guess i'll just use regular files. I wasnt using them because I want the software to be a standalone EXE file. – Aman Feb 15 '16 at 07:16
  • Check out the link I just added. Maybe it helps – xmorera Feb 16 '16 at 16:07