Program or Process Locked a file? Use Unlocker 1.8.7
This freeware program is excellent when you get those annoying error messages
Its called Unlocker and basically it can run in the background or it can be run manually so that when you delete a file it will let you know if any processes have a lock on that file or not.
It then allows you to kill that process and delete the offending file.
You can download Unlocker from here