如何使用VB.Net转到文本文档中的新行 [英] How to go to new line in a text document using VB.Net
本文介绍了如何使用VB.Net转到文本文档中的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用
File.AppendAllText("c:\mytextfile.text", "This is the first line")
File.AppendAllText("c:\mytextfile.text", "This is the second line")
如何让第二行文本出现在第一行下面,就像我按下了 Enter 键一样?这样做只是将第二行放在第一行旁边.
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.
推荐答案
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")
或者你可以使用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
这篇关于如何使用VB.Net转到文本文档中的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文