I have a set of nightly reports.
Sometimes I get the exception:
The process cannot access the file because it is being used by another proce
I was trying to start a Java program and got the message. Looking in Task Manager, there was already a Java task running (looping?) when I killed that process, my process was able to run.
The problem was the MailMessage in .NET was holding on to the file attachments. I had to do a dispose on the attachment and then it worked.
Use a tool like Process Explorer or Process Monitor.
here some tool(s) which tells and unlock locked files: http://ccollomb.free.fr/unlocker/
Filemon might be the tool you are looking for.
(or even Process Monitor which apparently has replaced FileMon.)