使用VB.NET覆盖文本文件中的特定行

前端之家收集整理的这篇文章主要介绍了使用VB.NET覆盖文本文件中的特定行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要做以下事情:

更改文本文件中的行

[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相关文章