c# redirect (pipe) process output to another process

前端 未结 2 1512
别跟我提以往
别跟我提以往 2020-12-05 08:17

I am trying to run a process in c# using the Process class.

Process p1  = new process();
p1.startinfo.filename =  \"xyz.exe\";
p1.startinfo.arguments = //i a         


        
2条回答
  •  旧时难觅i
    2020-12-05 08:47

    You can use CliWrap to make piping really easy, without the overhead of a console, and also completely x-platform:

    var output = File.Create("output.txt"); // stream is just one of the options
    
    var cmd = Cli.Wrap("xyz.exe") | output;
    await cmd.ExecuteAsync();
    

提交回复
热议问题