我需要执行以下操作:
更改文本文件中的行
[Path] = "c:\this\certain\path\"
用这一行
[Path] = "c:\that\other\newer\path\"
这些路径的长度肯定会不同,因此我需要替换引号中的内容,或者完全删除该行并输入一个新路径,但在同一位置,而不是附加到文档末尾。
最佳答案
这样就可以了
Dim thefile As String = "filepath"
Dim lines() As String = System.IO.File.ReadAllLines("filepath")
lines(number of line you want to replace) = "write what you want to replace here"
System.IO.File.WriteAllLines(filepath, lines)
关于vb.net - 使用 VB.NET 覆盖文本文件中的特定行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2050054/