|
-
Aug 19th, 2010, 09:38 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Log Reader Parser
So, I am trying to make a simple log parser that pulls info from a constant (real time updating) log file.
it is CONSTANTLY being updated, and i'm having issues...
Here's what I got so far:
Code:
Dim sFilename As String = My.Settings.chatlogloc
Debug.Print(sFilename)
Dim sFileReader As StreamReader
Dim sInputLine As String
Try
Dim x As Integer
Dim s As String
Dim y As Integer
Dim c As String
If Dir(sFilename.ToString) <> "" Then
sFileReader = System.IO.File.OpenText(sFilename)
sInputLine = sFileReader.ReadLine()
Do Until sInputLine Is Nothing
sInputLine = sFileReader.ReadLine()
x = InStr(sInputLine, ": ")
y = InStr(sInputLine, vbNewLine)
c = Mid(sInputLine, 1, x - 1)
s = Mid(sInputLine, x + 1)
s = s.Replace(" : ", "")
Debug.Print(s)
If sInputLine Is Nothing Then
'Clear the log file.
Debug.Print("End of FiLE")
My.Computer.FileSystem.DeleteFile(My.Settings.chatlogloc)
End If
Loop
sFileReader.Close()
sFileReader.Dispose()
End If
Catch ex As Exception
'Do nothing
Debug.Print(ex.ToString)
Finally
sFileReader.Close()
My.Computer.FileSystem.DeleteFile(My.Settings.chatlogloc)
End Try
Basically, its messing up when its time to rescan it. I can't use the 'New' on it, as it throws a error on the streamreader.
And if it's throwing an error with that, i'd be curious what other errors it will throw.
The file doesnt necessarily HAVE to be deleted, but it DOES have to be cleared out. (so the program doesnt have to reparse all the lines).
Any assistance would be helpful, as well as any generic improvements. (i'm new to this readbyline stuff.)
Thanks in advance guys!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|