Console Applications question

A

Alexandre Gomes

I've been searching for a clue for this but can't find one.

Is possible to create an aplication with something like:

"Decompressing... x%"

Where the x will be changing with the evolution of the decompression in
this case.
In this case I used decompressing but it could be anything like in Linux
or Dos where u can have an application in textmode.

Thanks
 
W

William Stacey [MVP]

Sure, you just need to fiddle with it a little.
Console.Write("Decompressing...\r");

while(true)
{
Console.Write("Decompressing...{0}%\r", var);
}

Note the carrage return but no line feed. You could also do this with
backspace(s) if you wish.
I did something similar with color in the MSH shell beta in a cmdlet.

This works if you don't munge your display with other output. Another idea
is to update the Titlebar instead with your status info and reset the bar
back to original when done.
 
A

Andrew Baum

Here is an example.

if(loop conditions)
{
string tmp = String.Format("Decompressing: {0}%",<percent>);
Console.Write(tmp);
Console.Write("".PadLeft(tmp.Length,(char)8));
}

-Andrew
 
A

Alexandre Gomes

William said:
Sure, you just need to fiddle with it a little.
Console.Write("Decompressing...\r");

while(true)
{
Console.Write("Decompressing...{0}%\r", var);
}

Note the carrage return but no line feed. You could also do this with
backspace(s) if you wish.
I did something similar with color in the MSH shell beta in a cmdlet.

This works if you don't munge your display with other output. Another idea
is to update the Titlebar instead with your status info and reset the bar
back to original when done.

Thanks for your tips, that helps.
If I need to use more than 1 line I can just fill the end of my line
with white spaces. Yet, that can be a mess because I do not know the
screen/window chars with. Any clue on this one? Also how can I put
colors in there? (What is MSH Shell?)
 
W

William Stacey [MVP]

If I need to use more than 1 line I can just fill the end of my line
with white spaces. Yet, that can be a mess because I do not know the
screen/window chars with.

Not sure I understand your need.
Also how can I put colors in there? (What is MSH Shell?)
Win32 pinvoke or look for xConsole library on google or WinConsole:
http://www.codeproject.com/csharp/winconsole.asp?target=Console|Enhancements

LH will have color console support, but that is down the road.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top