views:

149

answers:

2

I need FileSystemWatcher, that can observing same specific paths, and specific extensions. But the paths could by dozens, hundreds or maybe thousand (hope not :P), the same with extensions. The paths and ext are added by user.

Creating hundreds of FileSystemWatcher it's not good idea, isn't it?

So - how to do it? Is it possible to watch/observing every device (HDDs, SD flash, pendrives, etc.)? Will it be efficient? I don't think so... . Every changing Windows log file, scanning file by antyvirus program - it could realy slow down my program with SystemWatcher :(

A: 

Well try first and then you'll see if you run into troubles.

Trying to optimize something where you don't even know if there is a problem is usually not very effective.

Foxfire
Ok, I understand, but I thought that anybody have same experience, that could save my time for testing several methods :)
BlueMan
There are so many factors playing into this that it would likely be impossible to transfer other experiences.
Foxfire
A: 

You're probably right that creating 10,000+ FileSystemWatchers may cause a problem. If it does (as Foxfire says - test it), start with the easy consolidations -- ignore the extensions when setting up your FileSystemWatchers, and filter the events after you get them.

If that still results in too much resource usage, try intelligently combining paths in the same manner, perhaps even going so far as to only create one FileSystemWatcher per drive letter, and perform the rest of your filtering after the event is received by your code.

Jonathan