What’s the difference between Process
and ProcessStartInfo
? I’ve used both to launch external programs but there has to be a reason there are two ways to do it. Here are two examples.
Process notePad = new Process();
notePad.StartInfo.FileName = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs";
notePad.Start();
and
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "notepad.exe";
startInfo.Arguments = "ProcessStart.cs";
Process.Start(startInfo);
ProcessStartInfo(String, String) Initializes a new instance of the ProcessStartInfo class, specifies an application file name with which to start the process, and specifies a set of command-line arguments to pass to the application.
Start another application using your . NET code As a . NET method, Start has a series of overloads, which are different sets of parameters that determine exactly what the method does. The overloads let you specify just about any set of parameters that you might want to pass to another process when it starts.
They are pretty close to the same, both are from the Process class. And there are actually 4 other overloads to Process.Start other than what you mentioned, all static.
One is a static method way to do it. It returns the Process object representing the process that is started. You could for example start a process with a single line of code by using this way.
And the other is a member method way to do it which reuses the current object instead of returning a new one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With