Hello -
I have a VB6 utility that I am writing that cleans up files that are only needed temporarily. The utility is scheduled to run every two minutes although we would prefer it run more frequently.
The problem is, when the utility runs, any given file may be in use and therefore can't be deleted.
I am currently attempting to delete the file and trap any error that occurs, making the assumption that a lock/permission issue exists if the file is in use. In such cases, I loop a number of times until the file can be deleted and failing that I leave the file to be deleted later.
Most often this works fine, but in some cases the file seems to be deleted while the file is in use. This doesn't make sense to me but it is happening.
So my question is, is ther a better way to test if the file is in use. Maybe an API call?
Thank you.
- John Mercure
I have a VB6 utility that I am writing that cleans up files that are only needed temporarily. The utility is scheduled to run every two minutes although we would prefer it run more frequently.
The problem is, when the utility runs, any given file may be in use and therefore can't be deleted.
I am currently attempting to delete the file and trap any error that occurs, making the assumption that a lock/permission issue exists if the file is in use. In such cases, I loop a number of times until the file can be deleted and failing that I leave the file to be deleted later.
Most often this works fine, but in some cases the file seems to be deleted while the file is in use. This doesn't make sense to me but it is happening.
So my question is, is ther a better way to test if the file is in use. Maybe an API call?
Thank you.
- John Mercure