I want to call an executable (in my case, this is PNGOUT.exe) and grab its output from stdout. But it turned out to be tricky - the application uses some sort of control characters to replace previously printed output (display of progress), and C# classes happily record them and when I want to analyze the output string, I get serious headache. (It even took a while for me to figure out what's happening with my string)
I'm calling executable with 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;
}
I need either use different method that captures only final state of text in console, or somehow get rid of control characters in result
(not simply delete them, but "apply" them to string to achieve the final look). How can it be done?