Click here to Skip to main content
15,889,884 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When I try to open a file from MenuStrip, System calls "Format of file is not possible", Exception handled.
How can I try to load a whole file, so after I can to search in a file the expressions?
How I can to do it without "Exception handled"?

What I have tried:

string Theme1 = @"Tema-1-Polinomi-converted.doc";
richTB1.LoadFile(Theme1,RichTextBoxStreamType.RichText);

Also tryed for .txt:
string path = @"file.txt";
string readText = File.ReadAllText(path, Encoding.UTF8);
Posted
Updated 7-Jun-20 23:44pm

1 solution

DOC files aren't Rich Text, they are a binary data format that is proprietary to MS and cannot be directly loaded into a RichTextBox. Becuase it's a binary format, cjust translating it to Unicode won't work either.

You will have to convert the file to a format the RTB can understand before you load teh data. Google will help you find suitable converters.

And just what the heck does that have to do with an OpenFileDialog? Your code doesn't even use one!
 
Share this answer
 
Comments
Serafima Dolgan 8-Jun-20 6:51am    
It's because I see in Internet only with OpenFileDialog examples
OriginalGriff 8-Jun-20 7:07am    
I'm going to pretend that you didn't say that ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900