Unless I'm misreading your code on CodePlex, it looks like your utility loads in the entire file every time it changes. That might be fine for tiny files, but it would be a huge performance hit for larger ones (a few megs, for example).
Why not do it a bit more simply?
using (FileStream str = new FileStream(f, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
I just tested this with a quick console app... You can write to the file from outside without any problems. You can rename it, and the C# code will still function. You can TRY to delete it, but it won't actually disappear until the
is closed (and subsequent attempts to operate on it will fail). For a rolling log situation, that seems to be acceptable.
With this method, you can just keep track of your position in the file, and watch for the stream length to become greater than your current position. You can still use a
to catch the rename event, close your
, and wait for a new file with the original name.
The tool's visible functionality (Parameters,
matching, etc.) could still be very useful... Just need to tweak the internals.
Ian is a life-long computer programmer who, immediately after earning his B.S. in C.S., was snatched up by a certain Wall Street firm that would explode spectacularly a mere five years later. After fourteen years working for hedge funds, he finally escaped to a certain global tech company that shall remain nameless...
On an unrelated note, he's also a published Sci-Fi/Fantasy author.