What is the best way to check to see if a file is being accessed by another process? Specifically, if the file is being written, I want to restrict access in a For Each loop when using the FileSystemObject in the Scripting library. For example, I am looking for the code required in the 'FileIsLocked' function in the sample code below...
For Each objFile in objFolder
If Not FileIsLocked(objFile) Then
ProcessFile(objFile)
End If
Next objFile
For Each objFile in objFolder
If Not FileIsLocked(objFile) Then
ProcessFile(objFile)
End If
Next objFile