I want to call an executable file (in my case it is PNGOUT.exe) and grab its output from stdout. But it turned out to be difficult: the application uses some control characters to replace the previously printed output (displaying progress), and the C # classes happily write them, and when I want to parse the output string, I get a serious headache. (It even took me a while to figure out what was going on with my string)
I call the executable with the following method:
public static string RunPNGOut(string pngOutPath, string target) {
var process = new Process {
StartInfo = {
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true,
FileName = pngOutPath,
Arguments = '"' + target + '"'
}
};
process.Start();
var result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return result;
}
, , - result ( , "" ). ?