简体   繁体   English

C#Win32 Fire事件读取文件

[英]C# Win32 Fire event on file read

I've seen a few questions about this but all a few years old. 我已经看到了一些与此相关的问题,但都已经有好几年了。

I want to be able to detect if a file is read by another process. 我希望能够检测另一个进程是否读取了文件。 For example, if a text editor open's a file, I want to have a function to be able to get the name of the file that was read. 例如,如果文本编辑器打开了一个文件,我希望有一个函数能够获取已读取文件的名称。

I saw that you can use the FileSystemWatcher class in C# to watch a directory for file changes but they don't solve the problem, again I saw these on a 6 year old thread. 我看到您可以在C#中使用FileSystemWatcher类来监视目录中的文件更改,但是它们不能解决问题,再次在6岁的线程上看到了这些更改。

Has anything new been added to C# or Win32's API since then to allow file open detection? 从那以后,是否有任何新的东西添加到C#或Win32的API中以允许文件打开检测?

Thanks in advanced. 提前致谢。

确实,这是一个非常复杂的主题,您需要使用文件系统过滤器驱动程序( https://msdn.microsoft.com/windows/hardware/drivers/ifs/index )非常低级的东西,很难实现,我认为至少在.net世界中,没有简单的方法可以做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM