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

标签 vb.net parsing

我需要执行以下操作:

更改文本文件中的行

[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/

相关文章:

vb.net - 如何延迟 vb.net 程序直到文件操作完成?

ios - 带字典的 Swift 4 Codable 数组具有 String 和 Array 的值

c# - 使用 C# 使用 OleDb 解析 CSV

.net - winforms 应用程序中的窗口关闭事件

parsing - 我如何用 peg 语法解析它?

perl - R中的基本输入文件解析

parsing - haskell - 解析/读取 .pdf 文件的内容

VB.NET 在表单之间传递数据。如何捕获Dialogresult.Ok的结果

vb.net - 错误 : Could not write header for output file #0 (incorrect codec parameters ? ):无效的参数

java - 如何创建一个在用户登录后启动的桌面应用程序?