File in use error

When exiting an app I want to remove all files in appdata\roaming\myapp\temp (actual names are different)

When I try to delete a file I receive a 104 error. So I test with f.locked but that returns false…?
The file is in use obviously, but why does f.locked return false?

This is something deeper in the OS than simply a file property. The OS counts (somewhat) when a request comes to open a file and decrements when you close it.

Since these are temp files you likely created, you are probably not closing the stream after you create/opened the file. As a matter of rule I always .Close and = Nil the stream when I’m done with it.