问题
I was making a VB.NET application that can be used to edit, compile and run C programs. I used the Process.StartInfo.RedirectStandardOutput property. But I'm unable to redirect it to a textbox, since it is not of the string type.
How do I redirect the output coming from the cl.exe process to my textbox?
回答1:
You need to redirect into the TextBox's Text property. For example:
Dim proc As New Process
proc.StartInfo = New ProcessStartInfo("tracert.exe", "10.0.0.138") _
With {.RedirectStandardOutput = True, .UseShellExecute = False}
proc.Start()
TextBox1.Text = proc.StandardOutput.ReadToEnd
来源:https://stackoverflow.com/questions/2607865/redirecting-the-standard-output-input-error-into-from-a-textbox