I have a simple script that deletes the first n lines of a text file.
Const FOR_READING = 1
Const FOR_WRITING = 2
strFileName = \"C:\\scripts\\test.txt\"
Thanks to Ekkehard.Horner for finding my error.
Update:
Const FOR_READING = 1
Const FOR_WRITING = 2
strFileName = "C:\scripts\test.txt"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strFileName, FOR_READING)
strContents = objTS.ReadAll
objTS.Close
arrLines = Split(strContents, vbNewLine)
Set objTS = objFS.OpenTextFile(strFileName, FOR_WRITING)
For i= 0 To UBound(arrLines)
If ShouldSkip(i) Then
objTS.WriteLine arrLines(i)
End If
Next
Function ShouldSkip(i)
Dim arrSkipLines, x
arrSkipLines = Array(1, 22, 32, 42, 169)
For Each x In arrSkipLines
If x = i Then
ShouldSkip = True
Exit Function
End If
Next
ShouldSkip = False
End Function