Saving .txt files with rich text box?

Hi, im working on a notepad program. Im using a rich text box, and wanna know how to save .txt formats The problem is that when i save rich text files (.rtf) it works fine but when i save text files as (.txt) it shows some weird stuff like this:

=Save as RTF FILE TYPE=

Hi this is a test!

--------------------------------------------------

=Save as Txt file type=

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}

\viewkind4\uc1\pard\f0\fs17 hi this is a test\par

}

�

--------------------

how do i make the txt save not show the other stuff Thanks in advance.



Answer this question

Saving .txt files with rich text box?

  • Tiaan

    oh nvm lol the problem was that im an idiot. I had thaqt code there already but i just realized that at the end of the sub i put a line of code that made it resave the file with fonts lol srry
  • lawrence ZR

    The weird format you are seeing is the actual RTF format that the RichTextBox uses to display the formatted text.

    Assuming you are using the SaveFile() method of the RichTextBox class, set RichTextBoxStreamType.PlainText or RichTextBoxStreamType.UnicodePlainText (if your text contains Unicode chars) as the second argument to your call right after your destination file path or stream to save it as raw text.



  • Kfoutts

    didnt work =(

    i need it to do this: if the text file is being saved in .rtf format, then save it with fonts. else, save as plain text file.


  • Saving .txt files with rich text box?