Why does Console.Readline() have a limit on the length of text it allows?
This is a somewhat bizarre limitation on the Console API. I had this problem before and found the following solutions:
Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
From the following MSDN forum post:
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/51ad87c5-92a3-4bb3-8385-bf66a48d6953
See also this related StackOverflow question:
Console.ReadLine() max length?
A quick look at implementation with .NET Reflector gives this:
public static Stream OpenStandardInput()
{
return OpenStandardInput(0x100);
}
public static Stream OpenStandardInput(int bufferSize)
{
...
}
256 is the default value of OpenStandardInput, so I guess it's by design. Note this is only for .NET as the Windows API does not have this limit.