0

I am attempting to code something using C# where the user pastes a long string into the console, but it limits the amount I can paste.

I am hoping someone can help me.

Thanks in advance!

  • 3
    Are you saying that the user is running your console app and wants to paste text as input? Does that really have anything to do with C#? If the same would happen for other languages, it doesn't. Please read [this](https://stackoverflow.com/help/minimal-reproducible-example) and update your question accordingly. – jmcilhinney Mar 07 '23 at 03:56

2 Answers2

0

Thank you for the help, but I found the solution.

byte[] inputBuffer = new byte[1024]; 
Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
-1

Could it possibally be the buffer size? The console buffer size may be too small to display the entire paste. You can increase it's height and width with Console.BufferHeight and Console.BufferWidth Here is a code example `

Console.BufferHeight = 500;

Console.BufferWidth = 120;

Console.WriteLine("Please paste a string:");

string input = Console.ReadLine();

Console.WriteLine($"You pasted: {input}"); `

Aiden
  • 1
  • 1
  • Thank you for the suggestion, but I found the solution at https://stackoverflow.com/questions/5557889/console-readline-max-length – masternbslay Mar 07 '23 at 05:44