What process could have a hold on a downloaded file?

As written in Kaju on 2023R1 - #18 by Paul_Chance, I suddenly have a problem with a Kaju installation that used to work before, without knowing exactly when the issue arose. This is Windows exclusive, macOS is working, and I don’t think Kaju is to blame:

After downloading an update file, its verification will fail because the app cannot open the zip file in a temp folder for read access. File exists, is readable, but a BinaryStream as well as FolderItem.ReadFileMBS will fail, BS raising an IOException 32 which indicates that another process is having a grip on the file.
I tried to decouple the FileReceived URLConnection event from hashing, check its availability and some other stuff, but to no avail: Always the same error.
Any ideas how to find the process that might be accessing the file? Or how to mitigate this issue otherwise?

A downloaded file in the temp directory will attract the attention of anti-malware scanners. If that’s the case then you can try again in a few seconds.

If you have access to the system with the problem then try using Microsoft’s Process Explorer to search (ctrl+f) for the file in running processes.

We have always had intermittent access issues on MS-Windows when our app tries to unzip files it has downloaded. We made the process much more reliable by first trying to unzip the file a few times (with a short delay between each try) and if that fails, copy the file and then unzip that.

Thank you both! Uh, this would be much easier to handle if isReadable would be set to false …
Is it especially the temp folder that is subject to an antivirus interception or will Windows strike in App Support folder too?
And did I get you right that while read access might fail, copying will work? I didn’t try because I was almost certain it would fail too.

EDIT: For the latest, I can’t. Or I try too early. A CopyTo method call will result in an error 104 – file is currently in use. Think I’ll explore process explorer, thanks for the hint!

I’ve just had a look at the code as it was written a very long time ago. We download a file, sleep for 250ms, attempt to unzip the file and if that fails we copy it and then attempt to unzip the copy.

Thanks again!
I think I finally could fix it. It was NOT an antivirus system (I could retry for minutes and still not copy the file), but for reasons unknown this issue happened when the app’s main window was opened after Kaju’s window had shown. I have a file watcher installed there, but none that would watch a temp folder. So reasons completely unknown but currently it looks like a main window opening protection has fixed the problem.

IsWriteable and IsReadable refer to the file’s permissions, not to whether the file is locked by another process. The only way to detect a lock is to try to open the file.

1 Like