14 May, 2011

Can’t copy a file: The file is in use by another process…?

Often you run into the file copy issue (“the file is in use by another process”). Sometimes it is evident who is the active process using your file, other times it can be a little complicated to determine who is indeed holding on to your file you are trying to copy from or to.

Unable to copy

Well – to determine this in a quite robust way; you have the luxury of using ‘ProcesExplorer’ by SysInternals. Follow this recipe to see how to determine the exact process (PID) holding on to your assembly.

want to copy an assembly (FIMLoggingActivityLibrary.dll) like this:

Development machine –> Test machine

But, when I attempt this, I’m presented with the below dialogs:


File Copy failure

I know the name of the assembly I want to replace (FIMLoggingActivityLibrary.dll), so armed with this knowledge, I can use ProcessExplorer to find the hosting process:

Press ‘Find’ – ‘Find Handle or Dll…’

Process Explorer

next – enter the known part of the file name you want to search for:

Process identified

Here you have the name and ProcessID (PID) of the process holding on to your file. Now, either shut the process down in a nice fashion (in the above case using Control Panel – Services) or in a rude manner using Process Kill from Task Manager. This really depends on the situation what you do here.

Service Manager

When this process is stopped or restarted, you are able to copy the file initially requested.

Technorati Tags: ,

No comments:

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...