rich text box to file

Or if you wanted to do it the long way you could go like this, and save it into the desktop (at which you could do anyways with Voltes code :( ) bbbuuuttt just in case you need something elses text saved:


[VB]
Dim strSPath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "/TheName.html"
Dim HTMLFILE As System.IO.StreamWriter = New System.IO.StreamWriter(strSPath)
HTMLFILE.Write(TextBox1.Text)
HTMLFILE.Flush() Its always good to flush and close a stream
HTMLFILE.Close()
[/VB]
 
no need to use the streamwriter with the richtextbox really though :) , as voltface was saying use .SaveFile , adding to that you can specify the format of the text to save , eg:
Code:
RichTextBox1.SaveFile("D:\somepath.txt", RichTextBoxStreamType.PlainText)
 
Back
Top