VB.net RTF notepad app

April 27, 2011 at 17:40:27
Specs: Windows 7
I have created a tabbed notepad type app for work. Editing many txt/rtf/dat files at once seems easier if using an app that can handle all in one window.

My problem is when i save a file that is .txt, the formatting is changed. The file no longer looks the same when opened in notepad. Its as if the carriage returns or something is different.

Is there a way to save the formatting? I want to open the txt file with my rtf program and save back in txt format.

When the file is opened with my app, it appears as if nothing has changed but it is now very different if opened with notepad.

See More: VB.net RTF notepad app

Report •

April 28, 2011 at 16:18:26
I learned a little more about my issue.

When I open a txt file and then save it, I said the formatting was different. So I opened up the file before and after saving using a hex editor. The file before has hex values 0D and 0A after each line and after I save it the 0D is stripped out.

Is it possible to replace that 0D value preceding each 0A in VB.net?

Report •

April 28, 2011 at 17:05:04
ok, I fixed it.

Dim path As String = currentFile
Dim streader As New StreamReader(currentFile)
Dim s As String = streader.ReadToEnd
s = Replace(s, Chr(10), Chr(13) & Chr(10), 1)
streader = Nothing
Dim txtWriter As New StreamWriter(currentFile)
txtWriter = Nothing
RTB.SelectionStart = 0
RTB.SelectionLength = 0
RTB.Modified = False

Report •
Related Solutions

Ask Question