FileSystemWatcher questions

  • Thread starter Thread starter Marty McDonald
  • Start date Start date
M

Marty McDonald

I'm confused between FileSystemWatcher events (Changed, Created, Deleted,
Renamed) and the NotifyFilter. It seems that they are redundant and even
inconsistent at the same time.

For example, if I subscribe to the "Changed" event, and use a NotifyFilter
of "LastWrite", aren't they specifying the same thing?

Another example, if I subscribe only to the "Deleted" event, and use
NotifyFilter of "Size", what would that do?

Thanks for any clarification.
--Marty
 
Hello Marty,

Thanks for your post. I'd like to share the following information with you:
NotifyFilter of "LastWrite", aren't they specifying the same thing?

According to MSDN documentation, the "Changed" event may be triggered when
the size, attributes, security settings, last write, and last access time
are changed. With NotifyFilter set to LastWrite, it will go to your Changed
event handler only when last write change occurs. Please refer to MSDN
documentation for detailed information:

WatcherChangeTypes Enumeration
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemiowatcherchangetypesclasstopic.asp

NotifyFilters Enumeration
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemionotifyfiltersclasstopic.asp
NotifyFilter of "Size", what would that do?

"Deleted" event will be triggered when a file or folder is deleted.
NotifyFilter of "Size" does not take effect, because "Changed" event is not
specified.

Does this answer your questions?

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Tian,
Your post does answer my question. It is clear now! Thanks for the
information.
--Marty
 
Back
Top