Click here to Skip to main content
15,914,409 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:

Hi, am trying to display the progress of a process in percentage but sort of like when you use the command prompt to format a drive and it shows the percentage done. Problem is how to display the changing percentages on the same line. Console.Writeline(value) just wrote the %age on a new line. Anyone knows how to do this?
Posted

Use Console.Write(), and at the beginning of each string put a backspace character for as many non-backspace characters as you wrote the previous time.
 
Share this answer
 
Comments
Mwanzia_M 15-Apr-11 16:19pm    
thanks,sounds like what I need but,um, what is the backspace character look like? I know '\n' is for a new line and '\t' for tab but backspace doesn't ring a bell.
Mwanzia_M 15-Apr-11 16:26pm    
hold that thought, figured out it should be '\b'. Thanks for your help.
In addition to John's Answer:

Backspace is '0x8'.

—SA
 
Share this answer
 
Comments
Mwanzia_M 15-Apr-11 17:37pm    
gee, thanks but am just curious if all other escape literals have 'codes'. I mean, did you cram '0x8' or you have a list somewhere? Either way sounds like a messy affair.
Sergey Alexandrovich Kryukov 15-Apr-11 20:17pm    
I don't understand you question, sorry. Backspace code is unusual, it is processed by UI like a "characters" unlike other non-character key presses. There are raw several levels: raw codes from keyboard from all keys (including those like Shift), up and down, then OEM codes, system scan codes and characters and keyboard states on top; and on top of stack it depends on the active keyboard layout.
--SA
Mwanzia_M 16-Apr-11 15:26pm    
thanks 4 the update even as I digest this. oh well, it pays knowing what happens under the hood.

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