The front array sees some netizens to achieve such functions. So this is a code. Using system.diagnostics;
Class class1 {/// /// The primary entry point of the application. /// summary> [stathread] static void main (string [] args) {// creates a new process object = new process (); // When the process is to process, register an event Mycmdprocess.exited = new system.extHandler (mycmdprocess_exited); // To call the application cmd.exe mycmdprocess.startinfo.FileName = "cmd"; // Specify the parameter to the application / c execution string to be called The command then ends, calls IPConfig, and outputs the result of the IPConfig processing to the test.txt.txt. // this file does not exist, then automatically creates mycmdprocess.startinfo.arguments = "/ c ipconfig> Test.txt "; myCmdProcess.StartInfo.RedirectStandardOutput = true; myCmdProcess.StartInfo.UseShellExecute = false; myCmdProcess.StartInfo.CreateNoWindow = true; myCmdProcess.EnableRaisingEvents = true; myCmdProcess.Start (); Console.Read ();} private static void myCmdProcess_exited ( Object sender, system.eventargs e) {// The code here believes that everyone can understand. It is to read the contents in the test.txt file, showing try {system.io.streamReader myfile = new system.io.streamReader ("test.txt"); string mystring = myfile.readtoend (); myfile.close (); Console.writeLine (mystring);} catch (exception eXCPT) {console.writeLine (Excpt.Message);
}