[RESOLVED] [2.0] Possible? Determine if a windows-related event triggered -- then do something
Here's the situation:
I have a log file that I want to monitor. This log file will get updated based on certain events that happen within the program that writes the file (this program isn't written by me).
What I want to do is, if that log file gets updated (a new line is added), I want my program to know this happened.
I'm fairly certain I could rig a timer to check it every xx seconds. Check the filesize on the log, if it differs than the last time I opened it, then it's been modified. I don't want to do this because I assume it'll be pretty CPU intensive if I have to keep opening a file to check the last line every 1-2 seconds. This log file has the potential to become pretty big (upwards of 500-600kb, maybe even push 1mb).
Is there a way I can write something that magically knows if the file has changed without it being on a timer?
Re: [2.0] Possible? Determine if a windows-related event triggered -- then do something
Use a FileSystemWatcher component. It's in the VS Toolbox.
Re: [2.0] Possible? Determine if a windows-related event triggered -- then do something
Wow nice, worked perfect. I almost can't believe this component exists.