Home:ALL Converter>Open a text file in C#

Open a text file in C#

Ask Time:2012-09-06T15:05:34         Author:proud

Json Formatter

I'm writing a Windows-Forms Application in which I log some Data while the program is running and I write it in a temporary file with this code:

string path = Path.GetTempFileName();
byte[] text = new UTF8Encoding(true).GetBytes("Some Text");
using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Write, FileShare.None))
{
    fs.Write(text, 0, text.Length);
}

After the programm passed through I want to show/open the file in the Microsoft Editor. How can I do it. I googled around but I didn't find anything, maybe i searched with the wrong words. Hope you can help me.

Author:proud,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12294653/open-a-text-file-in-c-sharp
yy