04-05-2004, 05:39 AM
Join Date: Apr 2004
Location: Dublin, Ireland
[VB.NET] Problem with carriage returns when writing to text files.
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()
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.