Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在ASP.NET中读取控制台输出?_C#_Asp.net_Console_Stdout - Fatal编程技术网

C# 如何在ASP.NET中读取控制台输出?

C# 如何在ASP.NET中读取控制台输出?,c#,asp.net,console,stdout,C#,Asp.net,Console,Stdout,我想从控制台(cmd)读取数据,我尝试了以下代码 compiler.StartInfo.RedirectStandardOutput = true; compiler.Start(); compiler.StandardOutput.ReadToEnd(); 但它不起作用试试这个 Process compiler = new Process(); compiler.StartInfo.FileName = "SOME.exe"; compiler.StartInfo.Arguments = "

我想从控制台(cmd)读取数据,我尝试了以下代码

compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();
compiler.StandardOutput.ReadToEnd();
但它不起作用

试试这个

Process compiler = new Process();
compiler.StartInfo.FileName = "SOME.exe";
compiler.StartInfo.Arguments = "SOME ARG";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();    

var result=compiler.StandardOutput.ReadToEnd();

compiler.WaitForExit();
定义不工作。这可能会挂起。使用