I am trying to make the process respond as a string, so I can use it elsewhere in my code, this is the solution that I still have:
const string ex1 = @"C:\Projects\MyProgram.exe "; const string ex2 = @"C:\Projects\ProgramXmlConfig.xml"; Process process = new Process(); process.StartInfo.WorkingDirectory = @"C:\Projects"; process.StartInfo.FileName = "MyProgram.exe "; process.StartInfo.Arguments = ex2; process.StartInfo.Password = new System.Security.SecureString(); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; try { process.Start(); StreamReader reader = process.StandardOutput; string output = reader.ReadToEnd(); } catch (Exception exception) { AddComment(exception.ToString()); }
But when I run this, I get:
"The system cannot find the file specified" error in process.Start(); without process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true;
The code works fine, but it just opens a console window, and the whole process response is that I cannot use it as a string.
Does anyone know why I am getting this error or maybe another solution to my problem?
source share