简体   繁体   中英

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.

尝试:

Process.Start("Yourfile.txt")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM