Process.Start() get errors from command prompt window

前端 未结 3 829
梦如初夏
梦如初夏 2020-12-19 00:35

I\'m trying to Start command promt process with args. Now I want to obtain information about errors if they exist.

someProcess = System.Diag         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-19 00:52

    Process.StandardError Property:

    Gets a stream used to read the error output of the application.

    This should do what you want.

    Note

    To use StandardError, you must set ProcessStartInfo.UseShellExecute to false, and you must set ProcessStartInfo.RedirectStandardError to true. Otherwise, reading from the StandardError stream throws an exception.

提交回复
热议问题