Answer the question
In order to leave comments, you need to log in
Why doesn't C# Process RedirectStandardInput work with python.exe?
Hello. Why is this example
ProcessStartInfo info=new ProcessStartInfo("python");
info.RedirectStandardOutput = true;
info.RedirectStandardInput = true;
info.RedirectStandardError = true;
info.UseShellExecute = false;
//info.CreateNoWindow = true;
Process process=new Process();
process.OutputDataReceived += (s, e) =>
{
Console.WriteLine($"Output:{e.Data}");
};
process.ErrorDataReceived += (s, e) =>
{
Console.WriteLine($"Error:{e.Data}");
};
process.StartInfo = info;
process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
while (!process.HasExited)
{
Console.Write("Command:");
var line= Console.ReadLine();
process.StandardInput.WriteLine(line);
process.StandardInput.Flush();
}
Console.WriteLine("Done");
Console.ReadLine();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question