Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted (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 by Bob Burke
Posted
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...