c#: RedirectStandardOutput prevents exit exception?

Posted by user1743977 on Stack Overflow See other posts from Stack Overflow or by user1743977
Published on 2012-10-13T21:31:27Z Indexed on 2012/10/13 21:36 UTC
Read the original article Hit count: 226

Filed under:
|

All I want is to redirect standard output of a process to a file. Sounds easy, but everything I tried doesn't work:

1) putting a dos-style redirection in the list of arguments (e.g. "param1 param2 > output.txt") doesn't work,

2) using RedirectStandardOutput = true works, BUT, apparently the process does not through an exception when it exists. So the handler defined via process.Exited += ... doesn't catch anything. To be clear, once I remove the 'RedirectStandardOutput = true ' statement, it DOES catch an exception.

What am I doing wrong ?

Thanks, Ofer

© Stack Overflow or respective owner

Related posts about c#

Related posts about process