-->

从一个文本框重定向标准输出/输入/错误入/(Redirecting the Standard Out

2019-10-21 01:29发布

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

如何重定向输出从过程的cl.exe我的文本框来吗?

Answer 1:

您需要重定向到文本框的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


文章来源: Redirecting the Standard Output/Input/Error into/from a textbox