How many bytes can a textbox display?

Total Post:119

 1294  View(s)
Rate this:

I have made my program using Visual Studio.

I would like a TextBox to display the contents of file, but when the contents of file reaches hundreds of megabytes in size, a SystemOutOfMemoryException message appears.

How many bytes can fit into a textbox? So that I can limit the size of the data I read from the file.

  1. Post:378

    Re: How many bytes can a textbox display?

    Hi Goti,

    This sounds like a memory problem not a textbox problem which should have effectively unlimited capacity - max size of string = 2GB.

    A dirty way is to catch the OOM exception and try again with half the size or so. Perhaps you can break it into smaller sections and store them in a temporary file to be loaded on demand.

    If it's a really demanding application you can also target x64 or AnyCPU to get access to more memory on 64 bit Windows.