Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What’s the difference between Process and ProcessStartInfo in C#?

Tags:

c#

process

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);
like image 925
JimDel Avatar asked May 23 '10 00:05

JimDel


People also ask

What is ProcessStartInfo?

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.

How do I start a process in VB net?

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.


1 Answers

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.

like image 62
Brian R. Bondy Avatar answered Oct 20 '22 22:10

Brian R. Bondy