FileSystemWatcher questions

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
 
T

Tian Min Huang

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.
 
M

Marty McDonald

Tian,
Your post does answer my question. It is clear now! Thanks for the
information.
--Marty
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top