TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Stephen
NA
8
0
Problems with TextBox control
Apr 16 2007 12:33 AM
I'm writing a text editor in C#. It is nearly feature complete, but one problem remains: I want it to be able to open any kind of file and display it, regardless of size or format. I even want it to be able to properly open binary files, even if it shows up as strange characters (I.E. if you open an executable file in Notepad). The problem is that when I try to open a file, it only seems to show up properly if it is purely alphabetic and numerical characters. Opening a .exe file only shows the first to characters, basically the file signature, MZ. That being said, here's what I'm doing: 1) User selects a file through a dialog 2) Using StreamReader (or eqivalent, I've tried several, including FileStream, TextReader, etc.) I read the data from the file into a string. Opening a ~ 2.5 MB .exe file, I get a string with a length of 2,390,632. Seems reasonable. 3) I set the textBox1.Text property to the string I just created. The jist of the code is this: String text = stream.ReadToEnd(); MessageBox.Show("" + text.Length); //Debug: Checks the length textBox1.Text = text; MessageBox.Show("" + textBox1.Text.Length); //Debug: Checks the TextBox text length Strangely, even though text length is 2,390,632, setting the TextBox's Text property to text results in a length of 3. How setting the property to a string with the length of 2,390,632 results in the TextBox's text having a length of 3 is beyond me. Any ideas?
Reply
Answers (
2
)
developer and programmer
communication between two different .net applications