hi gyes.
I have problem to open txt file with containing text with font in richtextbox. Occures some kind of unrecognyzed error. so i need some script to open selected .txt file as .rtf file type. T.Y.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jun 15, 2014, 4:59 PM
If it's not working properly this might be the reason?
David HelfgottPosted Jun 15, 2014, 4:22 PM
VulpesPosted Jun 15, 2014, 4:15 PM
A plain text file can only store the characters of the text, not how they look.
If you need to store font, color etc. then you can create an .rtf file using Wordpad or Word and the RichTextBox can load it directly as this its native format. Of course, you can give such a file a .txt extension if you like though, personally, I wouldn't do this as it's likely to lead to confusion in the future.
David HelfgottPosted Jun 15, 2014, 3:58 PM
VulpesPosted Jun 15, 2014, 2:54 PM
richTextBox1.LoadFile(filePath);
To load a plain text file instead, I'd use:
richTextBox1.LoadFile(filePath, RichTextBoxStreamType.PlainText);