Bob Burke Posted April 5, 2004 Posted April 5, 2004 Private Sub butSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butSave.Click Dim save As New SaveFileDialog() save.Title = "Save Domain List As Text File" save.Filter = "Text files (*.txt)|*.txt" save.FilterIndex = 0 save.RestoreDirectory = True If save.ShowDialog = DialogResult.OK Then Dim contents As String Dim FS As FileStream = save.OpenFile Dim SW As New StreamWriter(FS, System.Text.Encoding.ASCII) contents = txtResults.Text() contents.Replace(vbCrLf, System.Environment.NewLine) SW.Write(contents) SW.Close() FS.Close() End If End Sub This the code I am using to write contents (which is the contents of a multiline textbox named txtResults) to a text file. When I view the textfile in Wordpad or Editplus it is fine but in Notepad all off the data is on one line and is seperated by glyphs... i.e. no carriage returns. I really need to be able to view this in Notepad and I'm also wondering why I can't? Can anyone give me any pointers or workarounds? Thanks a lot. ~Bob Quote
Administrators PlausiblyDamp Posted April 5, 2004 Administrators Posted April 5, 2004 what happens if you remove the line contents.Replace(vbCrLf, System.Environment.NewLine) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Bob Burke Posted April 5, 2004 Author Posted April 5, 2004 (edited) Same output as before, all of the data on one line seperated by glyphs. EDIT: Eek!! I had been using a rich text box instead of a normal text box... I had originally used a rich text box instead of a normal text box because I couldn't figure out how to get a normal text box to accept multiple lines. Sorry guys! Edited April 5, 2004 by Bob Burke Quote
Hamburger1984 Posted April 5, 2004 Posted April 5, 2004 what happens if you remove the line contents.Replace(vbCrLf, System.Environment.NewLine) ...maybe it's the same dumb mistake I made some times.. try this: contents = contents.Replace(vbCrLf, System.Environment.NewLine) Hope this helps! Andreas Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.