2012-05-10 41 views

回答

6

你问做什么可以做。例如,病毒扫描程序一直都在使用它。您可以使用Process Monitor轻松监控文件活动。您也可以使用FileSystemWatcher Class在C#中进行编程。但是试图阻止程序打开或试图阻止程序访问文件不能在C#中完成。您将需要使用C或C++。您需要创建一个File System Filter Driver。这是一个复杂的事情,但它正是你需要的。引用MSDN:

A file system filter driver intercepts requests targeted at a file system or another file system filter driver. By intercepting the request before it reaches its intended target, the filter driver can extend or replace functionality provided by the original target of the request. Examples of file system filter drivers include anti-virus filters, backup agents, and encryption products.

2

的Sysinternals提供了一个免费的工具,所谓的进程监视器,一个功能是附加到任意的Windows进程(包括.NET应用程序)和捕获系统调用,包括文件打开,关闭,读取等。

您可以在Process Monitor Download Page下载。

编辑

当我重读你的问题,我看到你问拦截,并可能抵消这样的操作。我相信FileSystemWatcher班将是您最好的选择,尽管我不认为它可以单方面取消文件操作 - 您需要建立某种合作机制来指示呼叫方放弃其操作。

相关问题