Reputation: 8337
How can I start the default program for an arbitrary file from .net?
Eg if I have a FileInfo
reference to a .mp3 music, I want to launch Windows Media Player (if that's set up as the default handler for the file type)
Consequently if I have .xls, I want to launch Excel with the file pre-opened.
How can I do this from code?
Upvotes: 1
Views: 2079
Reputation: 887195
You can simply call Process.Start(path)
to open any file in the default program.
Upvotes: 4
Reputation: 4658
Just use Process.Start
(MSDN-article)
Process.Start(pathToYourFile);
Windows will launch the appropriate application. Just watch out: Up until Windows 8, this will throw an exception, if there is no standard application for that file type.
Upvotes: 10