Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a textfile with the default editor in .NET Core

In .NET Framework I can simply do Process.Start(filename); butin .NET Core I get this exception:

System.ComponentModel.Win32Exception: 'The specified executable is not a valid application for this OS platform.'

How can I start testfile.txt with my default app? Thank you!

like image 223
BDevGW Avatar asked Feb 01 '20 16:02

BDevGW


1 Answers

Open it like such:

new Process
{
    StartInfo = new ProcessStartInfo(filename)
    {
        UseShellExecute = true
    }
}.Start();
like image 108
Ismael Padilla Avatar answered Oct 13 '22 20:10

Ismael Padilla