proud
proud

Reputation: 53

Open a text file in C#

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.

Upvotes: 1

Views: 453

Answers (1)

CloudyMarble
CloudyMarble

Reputation: 37566

Try:

Process.Start("Yourfile.txt")

Upvotes: 1

Related Questions