The following function determines if file is used by other application, or if it is accessible for binary read.
Function isFileUsed(ByVal fName As String) As Boolean
Dim fNum As Integer
' supply a file number that is not already in use
fNum = FreeFile()
' try to open the file for read
FileOpen(fNum, fName, OpenMode.Binary, OpenAccess.ReadWrite)
' FileOpen succeeded
' FileOpen failed
It works great.
Some applications keep also temp files while they are open (i.e. MS Office).
My problem is that this function will return false for those temp files (not in use), while the main file returns true (when it is open). Does temp file has a special attribute (I tried already the Temporary attr - its not that).
I realized that some of the temp files are hidden, but normal hidden files should pass this function so its not a good option for me.
So, let's put it more clear: Is there a way to track temp files that some applications keep while they're open ?