【发布时间】:2014-10-29 06:13:20
【问题描述】:
我想使用 vb.net 编辑文本文件中的特定行。 下面的示例是我在文本文件中的数据:
Port1.txt
数据1
数据2
数据3
数据4
数据5
数据6
数据7
我想将文本文件中的 data5(第 5 行)编辑为 dataXX。我该怎么做?
到目前为止,通过使用下面的代码,我只能访问所有列出的数据,而不是一行数据。
Dim path As String = "c:\Users\EliteBook\Desktop\Port1.txt"
Dim readText() As String = File.ReadAllLines(path)
Dim s As String
For Each s In readText
MsgBox(s)
Next
这将在 msgbox 中为我提供文本文件中列出的所有数据的输出。如何访问特定的数据行而不是所有数据?我已经根据 Nahum Litvin 的建议编辑了这个问题,通过 here
【问题讨论】: