
- VBForums
- .NET and More
- C#
- [RESOLVED] [2.0] Possible? Determine if a windows-related event triggered -- then do something
-
Nov 8th, 2006, 05:07 PM
#1
Thread Starter
Member
[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?
Last edited by ThisIsMyUserName; Nov 8th, 2006 at 05:10 PM.
-
Nov 8th, 2006, 05:18 PM
#2
Re: [2.0] Possible? Determine if a windows-related event triggered -- then do something
Use a FileSystemWatcher component. It's in the VS Toolbox.
-
Nov 8th, 2006, 05:57 PM
#3
Thread Starter
Member
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.

- VBForums
- .NET and More
- C#
- [RESOLVED] [2.0] Possible? Determine if a windows-related event triggered -- then do something
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
|