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

时间:2010-04-09 13:36:24

标签: c vb.net redirect process cl.exe

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

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

1 个答案:

答案 0 :(得分:1)

您需要重定向到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