Console App question

  • Thread starter Thread starter Pete
  • Start date Start date
P

Pete

Hello,

When using the format program in a command prompt in
Windows you get something similar to this:

Insert new disk for drive A:
and press ENTER when ready...
The type of the file system is FAT.
Verifying 1.44M
3 percent completed.

How can I print out an updating percentage like this in a
C# Console App without producing the folowing:

Insert new disk for drive A:
and press ENTER when ready...
The type of the file system is FAT.
Verifying 1.44M
1 percent completed.
2 percent completed.
3 percent completed.

Many thanks,

Pete
 
Pete said:
Hello,

When using the format program in a command prompt in
Windows you get something similar to this:

Insert new disk for drive A:
and press ENTER when ready...
The type of the file system is FAT.
Verifying 1.44M
3 percent completed.

How can I print out an updating percentage like this in a
C# Console App without producing the folowing:

Insert new disk for drive A:
and press ENTER when ready...
The type of the file system is FAT.
Verifying 1.44M
1 percent completed.
2 percent completed.
3 percent completed.

Something like this might do the trick:

using System;

public class ConsoleExample
{
public static void Main()
{
int value = 100;

while (value > 0)
{
Console.Write("Value: {0} %\r", value);
--value;
System.Threading.Thread.Sleep(250);
}
}
}

I hope this helps.

Anthony Borla
 
Back
Top