I'm trying to write the content of my textbox to a txt file.
My code works fine but my error is, when I open txt file I see
result As List(Of String) = New List(Of String)
convertedText.Lines = result.ToArray()
My.Computer.FileSystem.WriteAllText(mypath & "\convertedcontent.txt", convertedText.Text, False)
Writing to .csv and many other file types work fine but I don't know how to break lines for text file.
Thanks in advance
I would use
Dim path = System.IO.Path.Combine(mypath, "convertedcontent.txt") System.IO.File.WriteAllLines(path, result)
Otherwise you need to append
Environment.NewLine to each line, you can use
System.IO.File.WriteAllText(path, String.Join(Environment.NewLine, result))
You need to add
& vbCrLf to your strings (each line)
Not sure where you are getting your strings from.. but you will have to add the carrier return/Line Feed character to those strings, one at the end of every string.
Might just even loop through your array and add them there?
P.S. Some of the comments have quicker ways of getting there, but this is probably what happens behind the scenes...
for i = 0 to convertedText.Lines.count -1 convertedText.Lines(i) += vbCrLf next