Capture and display console output at the same time

前端 未结 2 1944
再見小時候
再見小時候 2021-01-22 11:09

MSDN states that it is possible in .NET to capture the output of a process and display it in the console window at the same time.

Normally when you set

2条回答
  •  礼貌的吻别
    2021-01-22 11:40

    See this answer here on SO which I posted code for a process to exec netstat an redirect the output stream to a Stringbuilder instance. The process creates a hidden window and is not visible...

    You can modify the code slightly by changing the values respectively

    ps.CreateNoWindow = true; <--- Comment this out...
    ps.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; <--- Comment this out...
    

提交回复
热议问题