How to execute/open whatever file in .NET
12,424
Solution 1
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute.aspx
Process proc = new Process();
proc.StartInfo.FileName = "file.doc";
proc.StartInfo.UseShellExecute = true;
proc.Start();
Solution 2
Use Process.Start and pass the file name as an argument. This requires that the file extension be associated with the correct program.
Comments
-
Aan almost 2 years
If I have a path of any kind of file (.doc , .pdf , .png ...etc) and I would like to open that file as it is opened via double click (no need to determine the host program). An example of what I mean is:
.doc
file needs to be opened via MS Word or whatever word processor exists in the machine and it is set as defualt word processor.