ShellExecute equivalent in .NET


Question

I'm looking for the .NET-preferred way of performing the same type of thing that ShellExecute does in Win32 (opening, printing, etc. for arbitrary file types).

I've been programming Windows for over 20 years, but I'm a complete newbie at .NET, so maybe I'm just looking in the wrong places. I'm currently using .NET 2.0 (VS C# 2005), but could use VS 2008 if need be.

If the only answer is to use P/Invoke, then I might be better just writing my small utility using Win32 anyway.

1
47
1/3/2015 4:07:06 PM

Accepted Answer

Process.Start.

Note that advanced uses (printing etc) require using a ProcessStartInfo and setting the Verb property.

65
11/3/2008 11:48:59 AM

System.Diagnostics.Process.Start.

I bet you had trouble finding it because it is in the System.Diagnostics namespace. "Diagnostics"? Usually with 20 years experience one thing you get good at is guessing at what something will be called in a new API/language, but this one tricked me.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon