I have a loop that finds duplicate lines in a .ini file. I can happily find the duplicate lines, and write new lines to the file using FileSystemObject, however... I can't seem to find out how to delete the duplicate lines. What I want to do is delete the lines by line number as I have identified the relevant line number already.
Is there a native way to do this, or is it a case of rewriting the file minus the duplicate lines?
Any help is greatly appreciated.
Thanks.
My method of finding the duplicate entry is as follows:
Do While Not file.AtEndOfStream
intLineNumber = intLineNumber + 1
strReadLineText = file.ReadLine
If strSearchText <> "" And InStr(strReadLineText, strSearchText) > 0 Then
session("message") = "Line Exists on " + Cstr(intLineNumber)
'' # delete duplicate line...
End If
Loop
file.Close()
You can see where my comment is, is where I wish to remove the line that is found.