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 process
How do I tell what process is holding on to the file? I am thinking that it is McAfee but I need to prove it.
Resolution. To resolve this problem, stop the application that is using port 80, and then start the Web site from IIS Manager. A simple way to see if port 80 is used by other program is to run "netstat -ano" in the command prompt. Find port 80 (Local Address 0.0.
This issue can occur if any of the following scenarios exist on your PC. You do not have permissions to the file or the file location. The file is on a location that is not currently accessible like a network location or an external drive that is not currently connected to the PC. The file has been moved or deleted.
What Causes FileNotFoundException. There are two main scenarios when the FileNotFoundException occurs: If a file with the specified pathname does not exist. If a file with the specified pathname is inaccessible, for example, if the file is read-only and is attempted to be opened for writing.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With