---
title: "How many bytes can a textbox display?"  
description: "How many bytes can a textbox display?"  
author: "Anonymous User"  
published: 2013-09-23  
updated: 2013-09-23  
canonical: https://www.mindstick.com/forum/1480/how-many-bytes-can-a-textbox-display  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How many bytes can a textbox display?

I have made my [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) using [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available).

I would like a [TextBox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) to display the contents of [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp), but when the contents of file reaches hundreds of megabytes in [size](https://www.mindstick.com/forum/159799/how-can-you-manage-the-size-of-mdf-and-ldf-files), a SystemOutOfMemoryException [message](https://www.mindstick.com/forum/12802/show-confirmation-message-yes-or-no-in-asp-dot-net) appears.

How many bytes can fit into a textbox? So that I can [limit](https://www.mindstick.com/forum/159824/explain-the-purpose-of-the-limit-and-offset-clauses-and-how-are-they-used-for-pagination) the size of the [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) I read from the file.

## Replies

### Reply by Sumit Kesarwani

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.


---

Original Source: https://www.mindstick.com/forum/1480/how-many-bytes-can-a-textbox-display

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
