Is there a way to display the contents from memory directly in a Notepad window?
Double-click on the file, making sure the association is set to Notepad.
If you want Notepad to show it without saving it to disk, you can open an instance of Notepad, get the handle for the window, then write the text directly into there. You will need to use Windows User APIs to do this.
I'm assuming that I understand your question. If the file already exists on the machine you can execute the following:
System.Diagnostics.Process.Start( "notepad.exe", "[PATH]\[FILE].txt");
If not then save the file locally and then run the above code.
Why do you need notepad to show some contents (which is in memory)?
If you are using winforms, you could put it in a textbox.
Sorry, if I have not understood your question correctly.
I would like to add to MrEdmundo's answer that the Isolated Storage is the right place to store the temporary txt file for Notepad.
The easiest way to accomplish this is to save the file and open it in notepad, however there are at least two other ways.
- Open Notepad then copy what you want to the clipboard, then using DDE force Notepad to paste. This is bad, because it potentially overwrites what the user may have been doing in the clipboard.
- The second way involves getting a window handle to the notepad Edit control, then doing a WM_SETTEXT to the window. This will not, however, work across privilege boundaries (such as for apps that run as administrator, but notepad runs as a normal user). This also involves getting down to Native level and doing P/Invokes. Not exactly an easy method.
Frankly, it's just easiest to save it to a file and load it.