Possible Duplicate:
How can I update the current line in a C# Windows Console App?
What i mean is that i have a for in a for loops.
For (x=0; x<this.Length;x++)
{
for (y=0; y<this.Length;y++)
{
Console.WriteLine("Working on file " + images[x] + " please wait");
}
}
The line Console.WriteLine("Working on file " + images[x] + " please wait"); Will write in the console window each images[x] file line under line. I want that it will write it once and then overwrite the same line and so on. Not line under line . Like counting "Working on file 0001 please wait" Then next line will replace the same one "working on file 0002 please wait"
I tried to put Console.Clear(); after the Console.WriteLine but then its like blinking doestn work smooth.
Instead of using WriteLine
which writes a carrage return and a line feed, only write the carrage return. That places the cursor at the beginning of the line, so that next line it written on top of it:
for (x=0; x<this.Length;x++) {
for (y=0; y<this.Length;y++) {
Console.Write("Working on file " + images[x] + " please wait\r");
}
}
You can use Console.Write and prepend \r like this:
Console.Write("\rWorking on file " + images[x] + " please wait");
And perhaps append a few spaces at the end too, just to make sure you erase previous content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With