vb.net - 如何使用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键一样?这样,只需将第二行放在第一行的旁边即可。

最佳答案

使用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 - 如何使用VB.Net转到文本文档中的新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10095155/

相关文章:

.net - 如何将自定义类的通用列表绑定(bind)到 datagridview 并仅在 VB.NET 中显示特定属性?

javascript - VB.NET 调用 Javascript 函数。如何在 VB.NET 完成之前让 javascript 函数完成?

c# - 用ildasm + ilasm打补丁单一方法可行吗?

vb.net - 在 VB.NET 中检测音乐是否结束

vb.net - 用于循环类属性的 Lambda 表达式

c# - 如何从单独的运行进程中捕获表单事件

vb.net - 函数不返回时,VB.NET中没有警告

mysql - 复选框列表选择的项目未获得选择并在字符串中插入空白值

vb.net - 存储值的最佳方法

vb.net - 如何在 vb.net 2005 中压缩文件