Redirecting the Standard Output/Input/Error into/from a textbox

坚强是说给别人听的谎言 提交于 2020-01-16 03:41:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!