C# Can';无法从控制台进程获取输出

C# Can';无法从控制台进程获取输出,c#,C#,这段代码在ipconfig.exe上运行良好,但在我的目标应用程序上却一无所获 Process p = new Process(); p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateN

这段代码在ipconfig.exe上运行良好,但在我的目标应用程序上却一无所获

Process p = new Process();
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = "miner.exe";
p.StartInfo.Arguments = command;
p.EnableRaisingEvents = true;

p.OutputDataReceived += OutputDataReceived;
p.ErrorDataReceived += ErrorDataReceived;

p.Start();
p.BeginOutputReadLine();
p.StandardInput.Close();
有人能告诉我哪里出了问题,我能做什么吗?目标应用程序是用C++编写的,我认为使用PrimTf进行输出。在论坛上,我看到一个家伙说他无法让这个应用程序在linux中使用管道。

代码看起来不错

若流程并没有将任何内容输出到标准输出,那个么您将无法捕获任何内容

通过在Windows上使用现有的输出重定向或将输出管道化到其他程序窗口/*nix-

tool.exe > output.txt  
tool.exe | more

经过测试,创建了文件,但其中没有任何内容。但若我正常运行应用程序,我会在窗口中看到文本!应该有办法把这篇文章弄出来))C++程序应该在控制台上写些什么吗?如果是,请注释掉CreateNoWindow行并重试如果正常运行(手动),它将显示在控制台窗口中运行的文本行您已经编写了p.StartInfo.CreateNoWindow=true和p.StartInfo.WindowStyle=ProcessWindowStyle.Hidden;。。。因此,没有控制台窗口被删除created@Taleeb,不,它什么也不做,当我关闭窗口时,我只得到一次“null”。