Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is it possible to display the output in a single line by updating the percentage of a check disk progress in the same line. 
For example, if I want to show a percentage of a check disk progress, as of now in my output it shows in new line for every step of output.I'd just like to update the percentage of it in the same line , and not have to put each percentage on a new line.

Stage 1: Examining basic file system structure ...
Progress: 0 of 120832 done; Stage:  0%; Total:  0%; ETA:   0:05:50    
Progress: 1238 of 120832 done; Stage:  1%; Total:  0%; ETA:   0:05:50  
Progress: 3585 of 120832 done; Stage:  2%; Total:  1%; ETA:   0:05:47 
Progress: 6798 of 120832 done; Stage:  5%; Total:  1%; ETA:   0:00:58

this is how i get the output which is queried in a string and displayed on a textbox control


What I have tried:

private void button1_Click(object sender, EventArgs e)
        {
            String cmd = textBox1.Text;
            if (cmd == "")
            {
                MessageBox.Show("Please Enter a command!", "Input error");
                return;
            }
            richTextBox1.Text = "Executing...\n";
            ExecuteCmd exe = new ExecuteCmd();
            exe.TestEvent += Exe_TestEvent;
            String result = exe.ExecuteCommand(cmd);
        }

        private void Exe_TestEvent(string s)
        {
            if (richTextBox1.InvokeRequired)
            {
                richTextBox1.Invoke(new MethodInvoker(delegate {
                    richTextBox1.Text += s + Environment.NewLine;
                    richTextBox1.SelectionStart = richTextBox1.Text.Length;
                    richTextBox1.ScrollToCaret();
                }));
            }
    }
Posted
Updated 31-Jan-18 22:00pm
Comments
Richard MacCutchan 1-Feb-18 4:16am    
Where are those messages being displayed? If that is just the output of a system command running in a command window then you have no control over the display.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900