473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Clear the Colsole Window

Hi Guys,

I have written a console application in C#. I wish to printout a percentage
to the screen as the program is running.

Does anyone know how to clear the console window?
or does anyone konw how to do this?

Thanks
Josh
Nov 18 '05 #1
2 1139

"Josh" <jo**@rb.com.auREMOVETOEMAIL> wrote in message
news:uJ**************@tk2msftngp13.phx.gbl...
Hi Guys,

I have written a console application in C#. I wish to printout a
percentage to the screen as the program is running.

Does anyone know how to clear the console window?
or does anyone konw how to do this?


Here's some links to look at:

http://support.microsoft.com/kb/q99261/

http://msdn.microsoft.com/library/de..._functions.asp

But in general it's better to stream information to the console. If you
need to show a progress bar, a winform is the right tool for the job.

David
Nov 18 '05 #2
Hi,

For displaying progress you can "hack" it by sending a carriage return (\r)
without new line (\n) thus overwriting the old value. Example:

static void Main(string[] args)
{
for(int i = 0; i < 100; i+=5)
{
Console.Write("\rProgress: {0}%\t\t\t", i);
System.Threading.Thread.Sleep(300);
}
Console.WriteLine("\rFinished\t\t\t\t\t");
Console.ReadLine();
}

For clearing completely the console window see:

http://support.microsoft.com/?kbid=319257

Hope this helps
Martin Dechev
ASP.NET MVP
"Josh" <jo**@rb.com.auREMOVETOEMAIL> wrote in message
news:uJ**************@tk2msftngp13.phx.gbl...
Hi Guys,

I have written a console application in C#. I wish to printout a percentage to the screen as the program is running.

Does anyone know how to clear the console window?
or does anyone konw how to do this?

Thanks
Josh

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: jcollins | last post by:
Is there a command in Python to clear the screen? That is without writing multiple blank lines. Thanks. Jim C
2
by: Rob Videtta | last post by:
Hi, Please Help! I have developed a custom JSP tag that produces Javascript to create a window and write HTML and Javascript to that window. This window displays an error message. The...
1
by: Guy | last post by:
I have 4 images on a page and when someone clicks on one of them I open a secondary window and write a few lines to it describing the image. If they don't close that secondary window however, and...
3
by: Mike Turco | last post by:
Is there a way to clear the debug window other than just sending a bunch of line feeds? Tanks -- Mike
3
by: JezB | last post by:
I want to clear some specific Session variables when the user closes a page. On my page I have a "return to ..." button which navigates back to the parent page from which it was invoked - under the...
5
by: =?Utf-8?B?UmljaA==?= | last post by:
The output window gets filled with stuff while I am debugging my app. Is there a way to programmatically clear the output window? I have read that there is currently no explicit method to do this...
7
by: Just Me | last post by:
I am writing a small windows applicationa and I am writing console.writeline data to the console window. But i wanted to clear the area before writing to the window. I found the console.clear...
2
by: owl | last post by:
and here I thought I was going to finally be able to change the world AND contribute back to python with my amazing clear screen extension - but I can't get it to work. ;( Copying from...
3
by: Nelluru | last post by:
Hi, I want to open user details or some data pages in a new window after he enters the username and password. I am able to open in a new window but the problem is that i am not able to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.