user1107685
user1107685

Reputation: 451

FileSystemWatcher.Filter - before or after buffer?

I'm working on a project with a very large amount of files being modified and created/deleted. There are some problems with multiple FSW internal buffers filling and having to be expanded.

I've found conflicting info online about whether ".Filter" filters out BEFORE or AFTER detected changes are added to the buffer. If actually after a single FSW with event sorting afterwards might make more sense.

Does anyone know here for sure which it is?

Thanks.

Upvotes: 4

Views: 249

Answers (1)

M.Babcock
M.Babcock

Reputation: 18965

FileSystemWatcher wraps the native W32 method ReadDirectoryChangesW which in turn is responsible for putting File System events in the supplied buffer. The Filter property is enforced on the CLR side after the event has already been buffered in a private MatchPattern method which tells the monitor whether to report the file event or not.

Use of the Filter property would unlikely help your current situation. Rather, it may be more advantageous to grow the InternalBufferSize value to avoid overrunning the buffer. Alternatively, there are a number of other file system event monitoring classes out there on the net that set out to solve this same problem.

Upvotes: 2

Related Questions