I have a large-ish text file which is being constantly appended with new information - the file is appended to by a Quickbasic program.
I wanted a VB application to monitor when the file had been modified, then read the new data into a list box; this is basically so I can monitor the text file "in real time" and have a nice slidey bar to look up older information.
I am using the following to open the file etc:
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Dim Line As String
Dim CurrNumLines As Long
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(filespec, ForReading, False)
' Obtain number of lines this time
Do While f.AtEndOfStream <> True
Line = f.readline
Then I was using the f.line property to determine how many lines there are before deciding which lines to append to my list box.
However, I would prefer not to have to read the entire file every time it is updated so....
Is there a way of setting the "line pointer" into a text file? What I'd like to do is, if the file has been modified, to set the line number to the first of the appended lines and just parse these into the list box.
So, it would be nice to be able to do:
f.line = LastLineRead+1
' Read lines from this point to the EOF
Is there any easy way of doing this with text files or do I have to access the file as binary/use the API etc...