简体   繁体   中英

how to dynamically set Notify Filter for file system watcher in VB.NET

I have values being pulled from a database that specify if the user has selected a specific notify filter to be associated with the file system watcher. My question is if the user has specified multiple notify filters how to assign that to the watcher?

I understand the format of how the notify filter should be supplied IE

fsw.NotifyFilter = NotifyFilters.FileName OR NotifyFilters.CreationTime OR ......

the problem is that i can assign each individual notify filter to the watcher using an if statement checking if the user has specified a certain notify filter and keep checking but that just sets the notify filter to the last checked value.

Using fsw.Notifyfilter += Notifyfilters.FileName does not work

Please Help

Ok, so you want something like this right?

If condition Then
  fsw.NotifyFilter = (fsw.NotifyFilter Or NotifyFilters.FileName)
Else If condition2 Then
  fsw.NotifyFilter = (fsw.NotifyFilter Or NotifyFilters.CreationTime)
...
End If

This is basically the equivalent of doing your OR'ing all at once, except broken down into multiple steps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM