MrGoodbytes
MrGoodbytes

Reputation: 294

View entire file in textbox

I noticed that when you open an .exe file in notepad, it shows up like this:

enter image description here

But when you open it into a windows forms textbox, it looks like this:

enter image description here

It's not just for .exe files either. the same thing happens with anything thats not plain text.

Can somebody tell me how I can make my textbox do that?

Upvotes: 4

Views: 68

Answers (2)

Alexandre Borela
Alexandre Borela

Reputation: 1616

Found the problem, the winforms's textbox stops rendering text when it finds a null byte. You can verify it like this:

textBox1.Text = "Hello\0World";

It'll just show the "Hello" part.

Upvotes: 3

apomene
apomene

Reputation: 14389

it seems like an encoding issue. View the encoding used in notepad and force your textbox to have the same, e.g

textBox1.Text = File.ReadAllText(file,Encoding.UT8);

Upvotes: 0

Related Questions