如何查询通过运行应用程序打开的文件. [英] How to query files that are open by running applications.

查看:80
本文介绍了如何查询通过运行应用程序打开的文件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要知道系统上应用程序打开的所有文件. E.x如果记事本打开C:\ abc.txt,那么查询时我应该收到"C:\ abc.txt".我需要这样做是因为我希望当用户使计算机处于睡眠状态时,必须关闭文件服务器上的所有文件.

我想我可以钩住打开文件的Windows消息.但这并不是完美的,因为我只能捕获应用程序运行后打开的文件.即使我想这样做,也仍然不知道我应该正确处理Windows消息.

您知道对此有什么解决方案吗?非常感谢.

Hi all,

I need to know all file which is opened by application on my system. E.x if notepad open C:\abc.txt then I should receive "C:\abc.txt" when querying. I need that because I want all files that are located on the file server must be close when user sleep the computer.

I think I can hook the Windows message that open the file. But it is not perfect because I can just catch the file which is open after my application runs. Even if I want to do it, then I still do not know what exactly the Windows message I should handle.

Do you know any solutions for this? Thanks a lot.

推荐答案

您应该查看目录而不是文件进行检测.这是一个示例:

http://articles.techrepublic.com.com/5100-10878_11-6165137.html [ ^ ]
You should watch a directory instead of a file to detect this. Here''s an example:

http://articles.techrepublic.com.com/5100-10878_11-6165137.html[^]


您可以使用FileSystemWatcher对象.

这是一个CodeProject示例:
C#:使用FileSystem Watcher监视文件或目录的应用程序 [
You could use the FileSystemWatcher object.

Here''s a CodeProject example:
C#: Application to Watch a File or Directory using FileSystem Watcher[^]

Good luck!


我不能使用FileSystemWatcher,因为它只能捕获Changed,Created,Delete和Renamed事件.如果它可以捕获Open,Close事件,那就没关系.
感谢您的答复.
I cannot use FileSystemWatcher because it can just catch Changed, Created, Deleted and Renamed events. If it can catch Open, Close events then it''s ok.
Thanks for your reply.


这篇关于如何查询通过运行应用程序打开的文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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