是否可以跟踪文件操作与.NET? [英] Is it possible to trace file operations with .NET?

查看:115
本文介绍了是否可以跟踪文件操作与.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能当一个文件操作称为某种方式 - 就像打开或关闭 - 我可以请求收益由操作系统之前处理它,如果可能通过的。NET ?如果.NET有这样的没有能力,我该怎么办呢?

Is it possible when a file operation is called somehow - like open or close - that I can handle it before the request proceeds by the operating system and if possible cancel it by .NET? If .NET has no abilities like that, how can I do this?

推荐答案

你问做什么可以做。病毒扫描程序,例如,做这一切的时候。您可以轻松地监控与进程文件活动监视器。您也可以使用 FileSystemWatcher类去做programmically在C#。但试图prevent从开放或试图访问不能在C#完成的文件停止程序的程序。您将需要使用C或C ++。您需要创建一个文件系统过滤驱动。这是一个复杂的东西来构建,但其正是你所需要的。引述MSDN:

What your asking to do can be done. Virus Scanners, for example, do it all the time. You can easily monitor file activity with Process Monitor. You can also do it programmically in C# using the FileSystemWatcher Class. But trying to prevent a program from opening up or trying to stop a program from accessing the file can not be done in C#. You will need to use either C or C++. You need to create a File System Filter Driver. It is a complex thing to build but its exactly what you need. To quote MSDN:

针对文件系统或其他文件系统过滤驱动的文件系统过滤驱动拦截请求。通过拦截该请求之前到达其预期的目标,过滤驱动器可以扩展或代替由请求的原本的目标提供的功能。文件系统过滤驱动程序的示例包括防病毒过滤​​器,备份代理和加密产品。

这篇关于是否可以跟踪文件操作与.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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