Friday, June 22, 2012

Open a file with default file extension in C#

[sourcecode language="csharp"]
var fileToOpen = "PATH_TO_FILE";
var process = new Process();
process.StartInfo = new ProcessStartInfo()
{
UseShellExecute = true,
FileName = fileToOpen
};

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

[/sourcecode]

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.

No comments:

Post a Comment

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...