Here's an example to start a process with arguments in C#:
main.cs538 chars21 lines
In this example, we create a new instance of the ProcessStartInfo
class, which allows us to specify the path of the executable to start and any arguments to pass to it. We then create a new Process
object and set its StartInfo
property to the ProcessStartInfo
object we just created.
We start the process by calling the Start
method, and then wait for it to exit by calling the WaitForExit
method. If the process generates any output, we can read it from its StandardOutput
stream.
Note that we've also set a few properties on the ProcessStartInfo
object to redirect the process's output to our program's standard output and hide the process's window. This is optional, but can be useful in certain scenarios.
gistlibby LogSnag