Change Notification
-
Hi, I want to write a program that send a notififcation when files or folders in a path has been changed. So I've used FindFirstChangeNotification and WaitForMultipleObjects (same as a sample in MSDN document). As I read the document when I use INFINITE for time-out of wait function, it will not be timed out. But in my sample after about one minute, wait function will be timed out. Do you know what's the problem? Mehdi
-
Hi, I want to write a program that send a notififcation when files or folders in a path has been changed. So I've used FindFirstChangeNotification and WaitForMultipleObjects (same as a sample in MSDN document). As I read the document when I use INFINITE for time-out of wait function, it will not be timed out. But in my sample after about one minute, wait function will be timed out. Do you know what's the problem? Mehdi
You should be using the
FileSystemWatcher
component instead. It already wraps all the native functionality up in an easy-to-use component. You can configure theFileSystemWatcher
to watch for new, changed, or deleted files and it will fire events when what you want to watch occurs (like changed files or directories) with information about what was changed (one tip: theChanged
event is fired three times for each change regardless of file size - after lots of research into event the native methods that theFileSystemWatcher
wraps, I still can't figure out why - just make sure your code accomodates that). As far as your problem goes, are you actually doing this using C#?INFINITE
is actually a pre-proc definition for 0xffffffff (you could declare this as a const in C#) and if you're passing this as a string, the function will most likely use the default timeout.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----