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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jun 15, 2014, 10:54 AM EDT
richTextBox1.LoadFile(filePath);
To load a plain text file instead, I'd use:
richTextBox1.LoadFile(filePath, RichTextBoxStreamType.PlainText);
David Helfgott7 reputationPosted Jun 15, 2014, 11:58 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 15, 2014, 12:15 PM EDT
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 Helfgott7 reputationPosted Jun 15, 2014, 12:22 PM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 15, 2014, 12:59 PM EDT
If it's not working properly this might be the reason?