整个计算机的Filewatcher(可选) [英] Filewatcher for the whole computer (alternative?)

查看:77
本文介绍了整个计算机的Filewatcher(可选)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个在整个计算机上的每个文件更改时获取事件的应用程序(以在文件位置/权限与我的应用程序的数据库之间进行同步).

I want to write an application that gets events on every file change on the whole computer (to synchronize between file locations/permissions and my application's database).

我当时正在考虑使用.net filewatcher类,但经过一些测试,我发现了以下限制:

I was thinking of using the .net filewatcher class but after some tests i found the following limitations:

1)文件监视程序具有缓冲区(http://msdn.microsoft.com/zh-cn/library/system.io.filesystemwatcher(v = vs.90).aspx):

1) The filewatcher has a buffer (http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.90).aspx):

如果在短时间内有很多更改,则缓冲区可能会溢出. 这会导致组件无法跟踪目录中的更改, 而且只会提供一揽子通知.加大尺寸 具有InternalBufferSize属性的缓冲区很昂贵,因为它 来自无法调换到磁盘的非分页内存,因此 保持缓冲区很小但又足够大,以免丢失任何文件更改 事件.为避免缓冲区溢出,请使用NotifyFilter和 IncludeSubdirectories属性,以便您可以过滤掉不必要的更改 通知.

If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification. Increasing the size of the buffer with the InternalBufferSize property is expensive, as it comes from non-paged memory that cannot be swapped out to disk, so keep the buffer as small yet large enough to not miss any file change events. To avoid a buffer overflow, use the NotifyFilter and IncludeSubdirectories properties so you can filter out unwanted change notifications.

因此,在整个计算机上,我可以获得一些我需要处理的事件(高峰时).即使在事件处理内部,我只是将事件信息添加到队列中,我仍然会错过事件.

So in the whole computer, I can get some large amount of events (in peak) that i need to handle. Even if inside the event handling I'm only adding the event info to a queue I still can miss events.

2)Filewatcher发生内存泄漏: http://connect.microsoft.com/VisualStudio/feedback/details /654232/filesystemwatcher-memory-leak 我自己检查了一下,没错,几天后,我的进程内存从20MB增长到250MB

2) Filewatcher has memory leaks: http://connect.microsoft.com/VisualStudio/feedback/details/654232/filesystemwatcher-memory-leak I checked it myself and it's true, after a few days my process memory grows from 20MB to 250MB

3)微软表示,我们应该对特定文件夹使用filewatcher(我不知道为什么):

3) Microsoft says that we should use filewatcher for specific folders (I don't know why):

使用FileSystemWatcher监视指定目录中的更改.

Use FileSystemWatcher to watch for changes in a specified directory.

因此,出于这些原因,我需要一个替代解决方案来创建我的应用程序.我知道我可以编写驱动程序,但我更喜欢将其作为.net解决方案(当然是基于win32 api).

So for these reasons i need an alternative solution to create my application. I know that I can write a driver but I prefer it to be a .net solution (based on win32 api, of course).

感谢您的帮助, 欧姆里

Thank you for your help, Omri

推荐答案

放置监视(尤其是同步通知)会降低系统速度.您可能可以利用我们的CallbackFilter产品,该产品提供了驱动程序和便捷的.NET API来跟踪文件更改.而且CallbackFilter支持更快的异步通知.可以享受折扣和免费许可证.

Putting monitoring (especially synchronous notifications) will slow down the system. You can probably make use of our CallbackFilter product which provides a driver and a handy .NET API for tracking file changes. And CallbackFilter supports asynchronous notifications which are faster. Discounted and free licenses are possible.

这篇关于整个计算机的Filewatcher(可选)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆