关于c#中procsess类的输出流问题
代码如下
Process p = new Process();
string path = "E: est est01.py";//待处理python文件的路径,本例中放在debug文件夹下
string sArguments = path;
p.StartInfo.FileName = @"E:pythonpython.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Response.Write(output);
执行到p.StandardOutput.ReadToEnd()这一句的时候就出现了“p.StandardOutput”引发了类型“System.InvalidOperationException”的异常这个报错,求大神解答!!!急急急!!!!!!!!!!!!!!!!!!!!!!!
不看其它的,你的文件路径是错的,C#的是转义符,它实际的(如路径中的)要用表示的
你的要改为
"E: est est01.py"
及
@"E:pythonpython.exe";
另外,你要确保该路径及文件的存在(程序若是参考别人的,必须按自己的环境修改路径的)