Home > DeveloperSection > Forums > How many bytes can a textbox display?
Goti Bandu

Total Post:119

Posted on    September-23-2013 3:43 AM


 1 Reply(s)
 894  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.

Sumit Kesarwani

Total Post:378

Posted on    September-23-2013 6:50 AM

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.

Don't want to miss updates? Please click the below button!

Follow MindStick