HOWTO: Monitoring file access with another process on Windows?

I am working on a program that handles image files. The problem I am running into is some of the images are very large and I have no idea when the copy process will be done. The code is currently written in C # and uses the FileSystemWatcher class to control files. The only problem is the absence of an event when another process DONE with the file.

The current logic is to keep track of the created and modified events and wait 5 seconds in the hope that by that time the copy process will be completed. While this works on my development machine, unfortunately clients are reporting issues with the entire process.

A few years ago when I wrote this code, I saw that at a lower level, I think it is part of the SDK DDK or something else, you can find out a lot more information about how another program accesses a file.

Can anyone talk about this and point me in the right direction? I expect this to be C ++ code, not C # code.


To answer some of the questions below:

The problem is that OTHER processes are copies of images in directories that my program controls. Once the images are fully copied, my program should start processing the images as soon as possible. The problem is that many images, sometimes hundreds of images, will be copied at one time. Since each image needs to be processed as quickly as possible, the system needs to know as soon as possible that the image has been completely copied and can be processed.

I totally understand that there is no way to do what I want to do with WinSDK, but I'm sure 99.9% is possible through WinDDK, maybe I have the wrong name, I Googled and got "Windows Driver Kit (WDK)". I'm sure SysInternals distracts all its cool tricks by using WDK-level features.

+3


source to share


1 answer


What you might be interested in is the sys internals procmon tool. Among other features, it controls file access, giving you a lot of details. No sources are available unfortunately, but here's a thread about a previous version (filemon) started by someone with a problem like yours.

Also you can look at an open source alternative , it may have the code you are looking for.



Alternatively, you can use ProcMon as a monitoring tool and analyze its output. Using the built-in filtering functions, you will be able to restrict log file entries to a specific folder and file access event type / data.

-1


source







All Articles