Piping in a file on the command-line using System.Diagnostics.Process

后端 未结 3 912
野的像风
野的像风 2020-12-01 15:01

I\'m trying to run a command-line program and piping in a file. The command works fine on the command-line, but I can\'t seem to get it to work with the Process object in C#

3条回答
  •  一整个雨季
    2020-12-01 15:39

    I'm not 100% sure but my guess would be that you have to manually push the data from test.dump to the process using its StandardInput property.

    Otherwise you could try using cmd.exe to execute the command:

    var psi = new ProcessStartInfo( "cmd.exe /c \"" + command "\"" );
    

    The reason for this is that the ">", "<" and "|" operators are implemented by the shell itself (cmd.exe).

提交回复
热议问题