如何使用VB.Net转到文本文档中的新行

Pic*_*kle 6 vb.net

运用

File.AppendAllText("c:\mytextfile.text", "This is the first line")
File.AppendAllText("c:\mytextfile.text", "This is the second line")
Run Code Online (Sandbox Code Playgroud)

如何将第二行文本显示在第一行下,就像我按下Enter键一样?这样做只需将第二行放在第一行旁边.

Mag*_*nus 9

运用 Environment.NewLine

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

或者你可以使用 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
Run Code Online (Sandbox Code Playgroud)