|
-
Jul 14th, 2005, 12:31 AM
#1
Thread Starter
New Member
Viewing a locked log file....
Hey All,
I'm currently trying to get a little VB.Net app running that has a
FileWatcher watching a log file being generated by the PortReporter
utility.
The filewatcher has no problem notifying of a change in file size,
however, i'm trying to read the changed text from the file and operate
on it.
The problem arises when i try to open the file, it doesn't matter what
i do, it always returns "An unhandled exception of type
'System.IO.IOException' occurred in mscorlib.dll".
I have tried all manner of opening the file and always seem to get the
error:
EG's:
Code:
Dim fiLogFile As New FileInfo(txtLogFileName.Text)
Dim fs As FileStream
fsFile = fiFile.OpenRead() <-- Errors on this line
Code:
FileOpen(1, txtLogFileName.Text, OpenMode.Binary)
Code:
Dim fs As New FileStream(txtLogFileName.Text, FileMode.Open,
FileAccess.Read)
The kicker is that i have no problems opening and viewing the file in
notepad and another editor called editplus.
Anyone happen to know a way to view a locked text file in vb.net?
Not being able to work out notepad's dirty little secret is driving me
nuts!
Thanks for any help you can give me 
Matt
-
Jul 14th, 2005, 01:13 AM
#2
Re: Viewing a locked log file....
If your code is in the FSW's event handler, are you sure it's not just that the previous operation hasn't actually finished with the file yet? Try putting a Sleep delay before trying to open the file. If that works then you know that that is the issue and you can look for a more permanent solution to that.
-
Jul 14th, 2005, 01:17 AM
#3
Thread Starter
New Member
Re: Viewing a locked log file....
Thanks for the suggestion.
I just tried isolating the file open code in it's own procedure and disabling the watcher completely (put the open code inside a button click event).
Same result......
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
|