I have an IIS webservice (commercial product) that writes files to a remote Windows file server using UNC.
From time to time, particularly when writing a large number of small files in a batch, the process fails. The Event Log shows that the process failed due to "The process cannot access the file because it is being used by another process."
When I go and have a look at the file, whatever was locking it is no longer locking it, and I can write to it without any issue.
So something is temporarily locking the file.
I can't use Process Monitor, OpenFiles, etc. because I need to catch the issue when it randomly and transiently occurs.
I can't monitor a specific file, because brand new files are written by the webservice each time. But they are written to a specific top folder and random subfolders.
It sounds a lot like AntiVirus, but our McAfee has OnAccess scan disabled on all of the machines involved.
Can run something on the servers to monitor file lock failure errors/events and catch the process info when they occur?
How can I catch which process is transiently locking the files as they are written?