Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to go to new line in a text document using VB.Net

Tags:

vb.net

Using

File.AppendAllText("c:\mytextfile.text", "This is the first line")
File.AppendAllText("c:\mytextfile.text", "This is the second line")

How do I make the second line of text appear under the first one, as if I hit the Enter key? Doing it this way simply puts the second line right next to the first line.

like image 871
Pickle Avatar asked Apr 10 '12 19:04

Pickle


1 Answers

Using Environment.NewLine

File.AppendAllText("c:\mytextfile.text", "This is the first line")
File.AppendAllText("c:\mytextfile.text", Environment.NewLine + "This is the second line")

Or you can use the StreamWriter

Using writer As new StreamWriter("mytextfile.text", true)
    writer.WriteLine("This is the first line")
    writer.WriteLine("This is the second line")
End Using
like image 132
Magnus Avatar answered Sep 21 '22 02:09

Magnus