开发者

C#/WPF FileSystemWatcher on every extension on every path

I need FileSystemWatcher, that can observing same specific paths, and specific extensions. But the paths could by do开发者_JAVA技巧zens, 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 :(


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜