I need to read all content of a file but keep only some of the content and append new content. So I tried to use READLINES filter the lines I need to keep then rewrite the file with the kept lines and new ones:
Dim paramLines As IEnumerable
paramLines = File.ReadLines(Path & "X.ini")
Dim paramFile As StreamWriter = New StreamWriter(Path & "X.ini", append:=False) ...
However, this gives an error on the third line: System.IO.IOException: ‘The process cannot access the file ‘…X.ini’ because it is being used by another process.’
I assume the “other process” is from the second line.
Is there a way to release or close the hold from FILE.READLINES?