将标准输出/输入/错误重定向到文本框中或从文本框重定向

我正在制作一个可用于编辑,编译和运行C程序的VB.NET应用程序。 我使用了Process.StartInfo.RedirectStandardOutput属性。 但我无法将其重定向到文本框,因为它不是字符串类型。

如何将来自cl.exe进程的输出重定向到我的文本框?

您需要重定向到TextBox的Text属性。 例如:

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