C # specify the output information of the windows console program,
The answer to this question is as follows. this is just a simple ipconfig command. if it is a complex command, such as oracle exp, it can be displayed during the call, it is cool.
Using System; using System. windows. forms; namespace WindowsApplication8 {public partial class Form1: Form {public Form1 () {InitializeComponent ();} delegate void dReadLine (string strLine); private void excuteCommand (string strFile, string args, dReadLine onReadLine) {System. diagnostics. process p = new System. diagnostics. process (); p. startInfo = new System. diagnostics. processStartInfo (); p. st ArtInfo. fileName = strFile; p. startInfo. arguments = args; p. startInfo. windowStyle = System. diagnostics. processWindowStyle. hidden; p. startInfo. redirectStandardOutput = true; p. startInfo. useShellExecute = false; p. startInfo. createNoWindow = true; p. start (); System. IO. streamReader reader = p. standardOutput; // capture the output stream string line = reader. readLine (); // read a row at a time while (! Reader. endOfStream) {onReadLine (line); line = reader. readLine ();} p. waitForExit ();} private void button#click (object sender, EventArgs e) {excuteCommand ("ipconfig", "", new dReadLine (PrintMessage);} private void PrintMessage (string strLine) {this. textBox1.Text + = strLine + "" ;}}/ * asked hovertree.com */
Recommended: http://www.cnblogs.com/roucheng/p/3521864.html