Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute/open whatever file in .NET

Tags:

c#

.net

c++-cli

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.

like image 575
Aan Avatar asked Oct 15 '11 16:10

Aan


1 Answers

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();    
like image 99
Erik Funkenbusch Avatar answered Sep 24 '22 01:09

Erik Funkenbusch