How can I monitor disk access for a certain file?
I want to us开发者_开发技巧e performance monitors to determine when a file is being accessed (read/write). Is this possible? If not, is there any other way? My OS is Windows Server 2008 R2, and I am writing the code in C#.
For what its worth, you can use FileSystemWatcher to monitor writes to a specific file.
Unfortunately I don't think there is an API available for doing this using managed code. If you need to hook a file system read or write event, you should look into writing a filter driver. Filter drivers are pretty low-level constructs and if it's only to do performance monitoring then it's probably not worth it. This API is often utilized by anti-virus or backup/replication software developers.
精彩评论