编写一个 .txt 文件,而不需要额外的一行?
Public Sub WriteTextFile(ByVal SourceToWrite As String, ByVal LocationToWrite As String)
Dim file As System.IO.StreamWriter
IO.File.Delete(LocationToWrite)
file = My.Computer.FileSystem.OpenTextFileWriter(LocationToWrite, True)
file.WriteLine(SourceToWrite)
file.Close()
End Sub
这是我用来写入 .txt 文件的模块。每次它都会添加一个带有空值的新行。不会真正打扰我,但它会添加,但随着时间的推移,一些原本应该只有 3 行的东西最终会变成 5000 行,有人知道如何在写入文件时不添加额外的行吗?
Public Sub WriteTextFile(ByVal SourceToWrite As String, ByVal LocationToWrite As String)
Dim file As System.IO.StreamWriter
IO.File.Delete(LocationToWrite)
file = My.Computer.FileSystem.OpenTextFileWriter(LocationToWrite, True)
file.WriteLine(SourceToWrite)
file.Close()
End Sub
This is a module I made to write to a .txt file. Every time it adds a new line with null value. wouldn't really bother me but it adds but then something that only suppose to have like 3 lines in it ends up with 5000 over time, anyone know how to not add that extra line while writing file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WriteLine() 函数将换行符附加到其输出。为了避免这种情况,请使用:
The WriteLine() function appends a newline character to its output. To avoid that, use: