当我运行以下代码(在一个事件中)删除字符串“DoNotShowSafeBootPages = Yes”时,我收到此错误“该进程无法访问文件'C:\ cfig.ini',因为它正在被另一个进程使用。”
Sub DeleteLineSM()
Dim line As String = Nothing
Dim line_to_delete As String = "DoNotShowSafeBootPage=Yes"
Using reader As New StreamReader("C:\cfig.ini")
Using writer As New StreamWriter("C:\cfig.ini")
While (reader.ReadLine()) IsNot Nothing
If [String].Compare(line, line_to_delete) = 0 Then
Continue While
End If
writer.WriteLine(line)
End While
End Using
End Using
End Sub
我要做的就是从文本文件中删除上面提到的字符串。有人可以帮助我吗?