I'm working on cook book Windows project, and I prepared some .rtf files to load it in RichTextBox. The problem is that the path of the file can't work at any computer, just mine. The code I used:
richTextBox1.LoadFile("C:\\Users\\nardeen\\Desktop\\cookproject\\cookingproject\\italian.rtf", RichTextBoxStreamType.RichText); In addition I tried with this but it didn't work:
string FilePath = System.Windows.Forms.Application.StartupPath + "\\italian.rtf"; richTextBox1.LoadFile(FilePath, RichTextBoxStreamType.RichText);
StartupPathin the debugger, what does it show? maybe you're one directory too far up, or in the bin folder, so you would need to move one up and then into the "cookingproject" folder. if you are going to publish your application, you should include the text file as an embedded resource, or have the installer put it in a runtime directory with a known relative path.