I implemented both suggestions plus also added in an update for the file position so it would take into account things that would be added. I am still only getting the last 2 characters of the last line of data. :( :cry:
'Shows that I am importing the correct namespace :)
Imports System.IO
'Globals
Dim currLogFile As String = ""
Dim filepos As Long = 0
Private Sub ReadLogFile()
If currLogFile = "" Then Exit Sub
Dim fs As StreamReader = File.OpenText(currLogFile)
Dim s As String = ""
Try
'Check to see if there is a position
If filepos = 0 Then
filepos = fs.ReadToEnd.Length
End If
'Get the end of the file
fs.DiscardBufferedData()
fs.BaseStream.Seek(filepos, SeekOrigin.Begin)
'Read the last line added
s = fs.ReadToEnd.ToString
'Used for testing purposes to see what was read in
MsgBox(s)
'Reset filepos to reflect added info
filepos = fs.ReadToEnd.Length
Catch ex As Exception
ShowErrorMessage(ex.ToString)
Finally
fs.Close()
fs.Dispose()
End Try
End Sub
Private Sub EQ2LogFileWatcher_Changed(ByVal sender As Object, _
ByVal e As System.IO.FileSystemEventArgs) Handles EQ2LogFileWatcher.Changed
'This is where it sets the path for the log file to be read from
Try
If currLogFile = "" Then currLogFile = e.FullPath.ToString
ReadLogFile()
Catch ex As Exception
ShowErrorMessage(ex.ToString)
End Try
End Sub
dminder
| Tue, 04 Dec 2007 13:40:00 GMT |