I have a winforms app that collects and compiles data and displays on a form. I want a user to be able to click a button that essentially exports that data to a txt file where they can print or save the text file.
I know about using StreamWriter txtFile = File.CreateText(@"C:\path\Foo.txt")
and I've used it for generating error logs and stuff, but that may not work because I don't necessarily want to create a new permanent file. Basically, what I'd like is:
User clicks a button, and then Notepad pops up with some info (based off of stuff stored in variables). The user can then decide if they want to save it or print it or whatever. When they close it, they'll be prompted to save (like Notepad always does) and then if they choose not to save, the file just disappears. If I use that above code, I'll end up with a new file created everytime a user clicks that button, which I don't want cuz then my drives will be full of 10,000 text files.
E: Okay, so a couple of people have suggested using this solution:
SendMessage to Notepad++ in C#
But that isn't working for me. I copied the code, dropped in a button, changed the Notepad++
to just Notepad
and it's not working. I added in the appropriate using
lines. Still not working. I'm not saying that this isn't the solution, I'm just saying that I can't get it to work.