是否可以使用.NET跟踪文件操作?

Hal*_*him 8 .net c# file

是否有可能以某种方式调用文件操作(如打开或关闭),我可以在操作系统请求进行之前处理它,如果可能,可以通过.NET取消它?如果.NET没有这样的能力,我该怎么做?

Ice*_*ind 6

你的要求可以做什么.例如,病毒扫描程序会一直这样做.您可以使用Process Monitor轻松监视文件活动.您也可以使用FileSystemWatcher类在C#中以编程方式执行此操作.但是,试图阻止程序打开或试图阻止程序访问该文件无法在C#中完成.您将需要使用C或C++.您需要创建文件系统筛选器驱动程序.构建它是一件复杂的事情,但它正是你所需要的.引用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.