- Posted by Admin on March 5, 2009
Suppose you have a winamp installed and it is a default program for playing mp3 and mpg file. Same way, if you have firefox installed and it is set as default to open html and swf files. To open particulr file in its own default application, you just need to double click or press 'enter' after selecting it.
.NET has a one statement feature to open a file in the default application. You just need to give the path of the file that you want to open. You can open any files in any windows event such as form closing, form load, button click, etc. Thanks to .NET's feature of developer productivity.
Here is that statement:
System.Diagnostics.Process.Start(path of the file);
You may also supply the arguments to the executable. E.g.
System.Diagnostics.Process.Start("path of the file","argument list seperated by space");
Examples
System.Diagnostics.Process.Start("c:\\songs\\newsong.mp3");
will open newsong.mp3 file in winamp
System.Diagnostics.Process.Start("c:\1.html");
will open 1.html in firefox
Thanks,