BDevGW
BDevGW

Reputation: 377

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!

Upvotes: 8

Views: 2995

Answers (1)

Ismael Padilla
Ismael Padilla

Reputation: 5576

Open it like such:

new Process
{
    StartInfo = new ProcessStartInfo(filename)
    {
        UseShellExecute = true
    }
}.Start();

Upvotes: 23

Related Questions