Clearing the Console
-
How can clear the DOS Console from a C# console application. ...the mind is not a vessel to be filled but a fire to ignited
This will be possible in either .NET 2.0 or Longhorn (no sure exactly which since release details are still sketchy) with
Console.Clear
, but for now you have to rely on other ways. One article here on CP presents such a way: http://www.codeproject.com/csharp/winconsole.asp[^]. There's also a programmatic way, but you'll have to P/Invoke some native functions: http://support.microsoft.com/support/kb/articles/q99/2/61.asp[^].-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
This will be possible in either .NET 2.0 or Longhorn (no sure exactly which since release details are still sketchy) with
Console.Clear
, but for now you have to rely on other ways. One article here on CP presents such a way: http://www.codeproject.com/csharp/winconsole.asp[^]. There's also a programmatic way, but you'll have to P/Invoke some native functions: http://support.microsoft.com/support/kb/articles/q99/2/61.asp[^].-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
but with this method, you give up your portability antoher method is, when you fill up the Console with \n (i mean the escape sequence) scio me nihil scire My OpenSource(zlib/libpng License) Engine: http://sourceforge.net/projects/rendertech
-
but with this method, you give up your portability antoher method is, when you fill up the Console with \n (i mean the escape sequence) scio me nihil scire My OpenSource(zlib/libpng License) Engine: http://sourceforge.net/projects/rendertech
Portability is often not possible anyway. Say I write a console app to manage the NICs in the machine - unless I add an abstraction layer, managing information on the NICs / in the OS is platform-dependent. Even with the code I gave, one could always abstract that, too. In any case, your idea works, it just isn't technically clearing the screen (this is most notable when you have a larger command/output buffer for your prompt and scroll).
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----