Cmd - A saner way to running external programs from C#
github.com
github.com
This is the same question I have when I see dynamic typing used to access data sources. Like reading a CSV file and doing 'row.Field1' instead of 'row["Field1"]'.
Is there really any benefit or point, other than being a cute hack?
* Doing the following will hang if the stdout buffer fills up:
var output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Take a look at Kudu (Azure's Git publishing platform) for the way they do it: https://github.com/projectkudu/kudu/blob/master/Kudu.Core/In...* You need to expose a way to capture `StandardError`.
(The reason for this is that the two streams are redirected to separate pipes, each of which has its own fixed-size buffer. If you forget to read from one pipe while you read from the other, its buffer fills up, and the writer - the program being executed - blocks. With standard error redirection turned off, the program writes directly to the console, which is safe.)