i have a basic C# Console application, it retrives logs from a website, but after like 100 lines, the old logs are deleted and the user cant scroll up and see them anymore, is there any way to increase the size it will save?
Console.SetBufferSize() buys you a bigger buffer. There are a few complications however. There's an upper limit on the maximum size and there's a bug in the argument validation code in the SetBufferSize() method. It reports that Int16.MaxValue is the largest number of lines you can ask for. That's an off-by-one bug. On Windows 7 you can use:
static void Main(string[] args) {
Console.SetBufferSize(Console.BufferWidth, 32766);
// etc..
}
On older operating systems (like XP) there a much tighter limit, the buffer size used to be restricted to 65536 bytes. I don't have them around anymore to check. The possibly valid code on those is:
static void Main(string[] args) {
var lines = 65536 / 2 / Console.BufferWidth;
Console.SetBufferSize(Console.BufferWidth, lines);
// etc..
}
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