Monitor file open c# .Net

守給你的承諾、 提交于 2019-12-24 13:27:41

问题


I want to build an app that needs to monitor the opening of the files but I don't find any way to can do it.

With FileSystemWatcher there is no option to can monitor the opening of the files. Just the created, removed and modified ones.

So I wonder if there is any functionality implemented in the advanced searches that could give me the infomration of the files opened after a concrete date. (At least in Mac it's possible but I am not sure if Windows has implemented this)

Other solution would be to develop a File System Filter Driver, but I find this way too hard


回答1:


I cant give you a direct answer (because I dont know) but since Microsoft publish the FileMon tool which does exactly what you are after, it seems that Windows does have a way of notifying file open, close and access. This is discussed here Getting a notification when a local file is accessed in windows but this only covers the change of files, not opening and closing. There is a way of getting all the files opened by a process discussed here Delphi - get what files are opened by an application which is possibly what FileMon is using, but there are caveats (i.e. its an internal OS API).

Hope this helps, sorry cannot give a direct answer.



来源:https://stackoverflow.com/questions/24739927/monitor-file-open-c-sharp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!