I was thinking of adding a simple bandwidth monitor to a console application and I was wondering if it would be possible to keep a line in the console window visible at all times. I could set something up manually to pass new console output into a method that would get the contents of the console, clear the console, add the bandwidth data on the first row, then rewrite each line of previous information back to the console, etc.. but that seems like a really hacky way to go about it, and I'd be limited to the amount of rows visible at once in the console window (no scrolling).
Any idea? Any built in functionality for this? Example:
STATS: Downloaded: 2599b, Uploaded: 754b <- this always stays at the top
constantly changing text
constantly changing text
constantly changing text
constantly changing text
constantly changing text
constantly changing text
constantly changing text
constantly changing text
constantly changing text
constantly changing text
constantly changing text
constantly changing text
You can use the other members of the Console class, such as CursorTop
and CursorLeft
to "move around" the cursor. If you move the cursor to the beginning of a line, and then use Console.Write
, it will "overwrite" the data at that location.
This lets you create situations like you're describing (by moving the cursor, writing, then moving back).
That being said, I typically would recommend using a GUI application as soon as you need to have multiple items being presented in a specific manner. You'll have much more flexibility (and it will likely be simpler).
If you don't intend to run full screen, you could just use Console.Title
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With