Is there a way to check if a file is in use?
Close any streams using the file in your application.
If the error is due to another running applicaton, it's best to just try the operation, and deal with the failure. If you check, then try to perform the operation, you create a race condition. If the delete fails (whether due to file in use or permissions), just deal with the problem then.