When writing programs, you often use the situation of calling executable programs. This article will briefly introduce the method of calling exe in C#. In C#, process operations are performed through the Process class. The Process class is in the package.
Example 1
Process p = ("");
();//Critical, wait for the external program to exit before it can be executed downward
Through the above code, you can call the Notepad program. Note that if you do not call the system program, you need to enter the full path.
Example 2
When you need to call the cmd program, using the above calling method will pop up an annoying black window. If you want to eliminate it, you need to make a more detailed setup.
The StartInfo property of the Process class contains some process startup information, among which the more important ones are
FileName
Arguments
CreateNoWindow Is it necessary to create a window
UseShellExecute Is it necessary to call the system shell program
The above parameters can make the annoying black screen disappear
= binStr;
= cmdStr;
= true;
= false;
();
();//Critical, wait for the external program to exit before it can be executed downward
or
startInfo = new ();
= binStr;
= cmdStr;
= true;
= false;
(startInfo);
();//Critical, wait for the external program to exit before it can be executed downward