Question text file issues

Reyn

Member
Joined
Dec 11, 2008
Messages
14
Programming Experience
1-3
I have written a text editor which is fully functional. However, whenever I save a text file in the .txt format. Whenever I open the file in the text editor it comes up just fine. However, if I use Notepad all of the carriage returns and such are missing. I am wondering if there is anything I can do about this.

EDIT: I've done some browsing around, and this thread
answers my problem, kinda. In the thread the guy talks about how he discovered that the RTB strips the #13#10 character of the #13. So whenever a basic text editor which does not utilize a RTB does not see the carriage return. He was unable to solve that, but was able to bypass it, and I am unsure exactly of what to make of his code. any insights would be appreciated.
 
Last edited:
VB.NET:
Me.RichTextBox1.SaveFile("notepad.txt", RichTextBoxStreamType.PlainText)
 
Thank you JohnH. Is there a way to work that into this code:

VB.NET:
            Try
                ioFile = File.OpenWrite(Me.FileName)
                'convert the contents of the TextBox to an array of Bytes
                ioWriter = New StreamWriter(ioFile)
                'and write to the file
                ioWriter.Write(rtxtEditor.Text)
                'and now we're not dirty
                Me.Dirty = False
            Catch ex As Exception
                ' display exception errors
                MessageBox.Show("Ther was an error while attempting to save the file of type: " & ex.Message, _
                                "SimpEdit Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Finally
                ' close file and writer
                ioWriter.Close()
                ioFile.Close()
            End Try
 
Yes, just replace your code in Try block with the one I posted.
 
Back
Top