[英]Redirect Standard Output with Shell Execute
我理解如何從C#
中的Process
對象重定向StandardIO
流。 但是,我必須使用ShellExecute
來執行特定命令。
因此,我無法重定向這些我需要用於記錄目的的流。
我試過像這樣重定向它:
procStart.FileName = m1g;
procStart.Arguments = ">> output.txt";
此時我計划只讀回文本文件,但這似乎不起作用。
可以這樣做嗎?
管道命令由cmd.exe
實現。 因此,您需要運行cmd /c
並將可執行路徑添加為參數
Process.Start("cmd.exe", "/c " + yourexecutablecommandline + " >> output.txt" );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.