execute/open a program in c#

.net, c#

Solution

You can use the System.Diagnostics.Process.Start method.

Process.Start("notepad.exe");

It will work with files that have associated a default program:

Process.Start(@"C:\path\to\file.zip"); 

Will open the file with its default application.

And even with URLs to open the browser:

Process.Start("http://stackoverflow.com"); // open with default browser

Agree with @Oliver, ProcessStartInfo gives you a lot of more control over the process, an example:

ProcessStartInfo startInfo = new ProcessStartInfo();

startInfo.FileName = "notepad.exe";
startInfo.Arguments = "file.txt";
startInfo.WorkingDirectory = @"C:\path\to";
startInfo.WindowStyle = ProcessWindowStyle.Maximized;

Process process = Process.Start(startInfo);

// Wait 10 seconds for process to finish...
if (process.WaitForExit(10000))
{
     // Process terminated in less than 10 seconds.
}
else
{
     // Timed out
}

Problem

Is there a solution/references on how to open or execute certain window programs in C#? For example if i want to open WinZIP or notepad application? Example on the line of codes are more helpful. But anything are welcomed. thank you.

Original source