FileSystemWatcher question
-
Hiya all. I instantiated a filesystemwatcher and set it to monitor a directory filtered with a specific file. Then I made a method which handles the Changed event from the filesystemwatcher.... however when I save/alter the file the watcher monitors - I get the event called twice. Does anybody know why? Or possible what I need to look for?
-
Hiya all. I instantiated a filesystemwatcher and set it to monitor a directory filtered with a specific file. Then I made a method which handles the Changed event from the filesystemwatcher.... however when I save/alter the file the watcher monitors - I get the event called twice. Does anybody know why? Or possible what I need to look for?
When I first used this class I had this problem - but I don't have the problem anymore. To resolve my issue I no longer listen to CHange event, but to the Created, Renamed and Deleted events instead. Depends on what you need to know, but these covered my requirements.
Stuart Wells Software Engineer
-
When I first used this class I had this problem - but I don't have the problem anymore. To resolve my issue I no longer listen to CHange event, but to the Created, Renamed and Deleted events instead. Depends on what you need to know, but these covered my requirements.
Stuart Wells Software Engineer
It's because a changed-event fires more than you probably expect, for example: - When you create a file - When you delete a file - When you rename a file - ...
-
When I first used this class I had this problem - but I don't have the problem anymore. To resolve my issue I no longer listen to CHange event, but to the Created, Renamed and Deleted events instead. Depends on what you need to know, but these covered my requirements.
Stuart Wells Software Engineer
I have a file, in which I need to monitor changes, so I can't use any of the others. The file exits, so it isn't because it gets created that the watcher triggers twice. Both events are the "Changed" event.
--------------------------- 127.0.0.1 - Sweet 127.0.0.1
-
I have a file, in which I need to monitor changes, so I can't use any of the others. The file exits, so it isn't because it gets created that the watcher triggers twice. Both events are the "Changed" event.
--------------------------- 127.0.0.1 - Sweet 127.0.0.1
I don't know for sure, but maybe you get one event for the content change, and one for the update of the LastWriteTime ?
Luc Pattyn
-
I have a file, in which I need to monitor changes, so I can't use any of the others. The file exits, so it isn't because it gets created that the watcher triggers twice. Both events are the "Changed" event.
--------------------------- 127.0.0.1 - Sweet 127.0.0.1
It depends on the file too. If it's a Word document, for example, you're not opening the orignal file. You actually open a copy of it. When you go to save the changes, the file is actually written to the temporary copy (Changed event), then the original file is deleted (Changed event) and the temporary file is renamed (Changed event) to the orignal filename.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
It depends on the file too. If it's a Word document, for example, you're not opening the orignal file. You actually open a copy of it. When you go to save the changes, the file is actually written to the temporary copy (Changed event), then the original file is deleted (Changed event) and the temporary file is renamed (Changed event) to the orignal filename.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
I don't know for sure, but maybe you get one event for the content change, and one for the update of the LastWriteTime ?
Luc Pattyn