Our client (a winforms app) includes a file-browser. I’d like the user to be able to open the selected file using the shell’s default handler. How do I do that? I’ve read that I should use the Win32 API rather than the registry, but I’d prefer a solution that involves only .NET.
Share
EDIT: Newer, simpler answer.
You can indeed just use
Process.Start(filename). This is specified in the docs forProcess.Start:EDIT: Original, complicated answer:
If you use
Process.Startwith the file as the “executable” and specifyUseShellExecute = trueit will just work. For example:That opens test.txt in Notepad.
In fact,
UseShellExecute=trueis the default, but as it’s definitely required I like to specify it explicitly to make that clearer to the reader.