Question

Is there a way to display the contents from memory directly in a Notepad window?

Was it helpful?

Solution

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.

OTHER TIPS

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.

The easiest way to accomplish this is to save the file and open it in notepad, however there are at least two other ways.

  1. 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.
  2. 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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top