I got a program that I'd like to output to a textbox but I'm having an issue with the progress bar. All the stdout from the app displays correctly except once I get to a progress bar:
00 00 00 01 01 01 02 02 02 etc... [/CODE]
I made this code to handle it:
[CODE] string o = ""; string pattern = @"(\d{1,2}\%)"; Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase); while (!process.HasExited) { StringBuilder output = new StringBuilder(process.StandardOutput.ReadLine()); MatchCollection matches = rgx.Matches(o); if (output.ToString () != o){ if (matches.Count > 0) { this.txtOutputLog.AppendText(output + System.Environment.NewLine); } else { this.txtOutputLog.AppendText(output + System.Environment.NewLine); } Application.DoEvents(); } o = output.ToString(); } [/CODE]
but still get this:
[CODE] 01 02 03 04 05 [/CODE]
How can I get the progress bar to print on one line? I've also tried using "\r".
Question
DPyro
I got a program that I'd like to output to a textbox but I'm having an issue with the progress bar. All the stdout from the app displays correctly except once I get to a progress bar:
I made this code to handle it:
string o = "";
string pattern = @"(\d{1,2}\%)";
Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
while (!process.HasExited)
{
StringBuilder output = new StringBuilder(process.StandardOutput.ReadLine());
MatchCollection matches = rgx.Matches(o);
if (output.ToString () != o){
if (matches.Count > 0)
{
this.txtOutputLog.AppendText(output + System.Environment.NewLine);
}
else
{
this.txtOutputLog.AppendText(output + System.Environment.NewLine);
}
Application.DoEvents();
}
o = output.ToString();
}
[/CODE]
but still get this:
01
02
03
04
05
[/CODE]
How can I get the progress bar to print on one line? I've also tried using "\r".
Link to comment
https://www.neowin.net/forum/topic/1146842-c-output-command-line-app-progress-bar-to-textbox-on-one-line/Share on other sites
21 answers to this question
Recommended Posts