I'm writing small console app for comunicate with chess engine. I'm setting process class properly and I can set input, but I can not capture output. With this starting parameters startInfo.RedirectStandardInput = true; startInfo.RedirectStandardOutput = false;
input is possible. When I'm setting startInfo.RedirectStandardOutput = true;
only empty console window is starting, no input possible. I saw this topic Catch console input-output and it's marked as accepted but it is not working for me.
For now my Program (how here I can read last line of output):
var position = File.ReadAllText("C:\\pos.txt");
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = false;
startInfo.UseShellExecute = false;
startInfo.ErrorDialog = false;
startInfo.FileName = "C:\\engine.exe";
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
process.StandardInput.WriteLine("position startpos moves " + position);
process.StandardInput.WriteLine("go");
System.Threading.Thread.Sleep(500);
process.StandardInput.WriteLine("stop");