RSS

Open a file with default file extension in C#

22 Jun
var fileToOpen = "PATH_TO_FILE";
var process = new Process();
process.StartInfo = new ProcessStartInfo()
{
UseShellExecute = true,
FileName = fileToOpen
};

process.Start();
process.WaitForExit();

UseShellExecute parameter tells Windows to use the default program for the type of file.

WaitForExit will cause your application to wait until the application luanched has been closed.

Advertisements
 
Leave a comment

Posted by on June 22, 2012 in C#.Net

 

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: