Resolved Net 5 and Process.Start("C:\JUNK.txt")

aaaron

Well-known member
Joined
Jan 23, 2011
Messages
216
Programming Experience
10+
Process.Start("notepad.exe")

Process.Start("C:\JUNK.txt")

I just checked - these still work OK on 4.8.

The second one exceptions in 5.0 because it not an executable file.

I've searched and can not find a statement saying Net5 changed this behavior.

Did it?

Should the second line work as far as you know?
 
Solution
When you use the operating system shell to start processes, you can start any document (which is any registered file type associated with an executable that has a default open action) and perform operations on the file, such as printing, by using the Process object. When UseShellExecute is false, you can start only executables by using the Process object.
The default is true on .NET Framework apps and false on .NET Core apps.
It was changed with .Net Core, and .Net 5 is a succession to .Net Core. When you don't specify StartInfo properties the default is used, so here UseShellExecute is...
When you use the operating system shell to start processes, you can start any document (which is any registered file type associated with an executable that has a default open action) and perform operations on the file, such as printing, by using the Process object. When UseShellExecute is false, you can start only executables by using the Process object.
The default is true on .NET Framework apps and false on .NET Core apps.
It was changed with .Net Core, and .Net 5 is a succession to .Net Core. When you don't specify StartInfo properties the default is used, so here UseShellExecute is false. Configure a ProcessStartInfo and Process.Start that.
VB.NET:
Process.Start(New ProcessStartInfo("JUNK.txt") With {.UseShellExecute = True})
 
Solution
Process.Start(New ProcessStartInfo("notepad.exe"))
Process.Start(New ProcessStartInfo("C:\JUNK.txt") With {.UseShellExecute = True})
Process.Start(New ProcessStartInfo(tempFilePath) With {.UseShellExecute = True})
All work.

Thanks
 
Back
Top