Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The process cannot access the file because it is being used by another process

Tags:

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.

like image 680
Greg Finzer Avatar asked May 18 '09 14:05

Greg Finzer


People also ask

Is the process Cannot access the file because another process IIS?

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.

Why is it saying Windows Cannot access the specified device?

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.

When a file with specified path does not exist or the file exists but Cannot be accessed when it throws?

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.


2 Answers

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.

like image 179
Greg Finzer Avatar answered Nov 07 '22 07:11

Greg Finzer


Use a tool like Process Explorer or Process Monitor.

like image 29
C. Ross Avatar answered Nov 07 '22 05:11

C. Ross