Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sometimes when I'm working in Windows I'll get this prompt when I try to delete a directory:

Folder In Use
The action can't be completed because the folder is open in another program
Close the folder and try again.

However, the folder isn't "in use" at all, and I don't have it open. So how can I delete it short of rebooting?

share|improve this question

15 Answers 15

up vote 35 down vote accepted

Process Explorer from Sysinternals will let you search through the handles and DLLs. Search for the directory and find out which process is "using" the folder.

From there, you have the ability to either shut down that process, or just close that particular file handle. Be sure about what you're doing when working with the file handle directly, and make sure it's not being used by some important process.

share|improve this answer
1  
But how I find directory which is used by process? –  Johnny_D Sep 11 '13 at 10:14
    
Use Ctrl-F and enter the name of the folder above the one you are trying to delete. –  MikeMurko May 6 at 20:58
1  
There is now a native GUI for Windows, see my answer below. –  bcorso Jun 27 at 20:48

Try this nice tool: http://www.emptyloop.com/unlocker/.

share|improve this answer
4  
A common culprit on my end is TSVNCACHE, a helper program for TortoiseSVN. –  Lasse V. Karlsen Jul 15 '09 at 17:19
    
I've had great luck with Unlocker –  spaetzel Jul 15 '09 at 17:20
    
I do prefer Unlocker, because it "unlocks" a lot of processes using the file in a few clicks and without killing them. You can put its shortcut on sendto folder to do it easier. –  kokbira Jun 11 '12 at 12:45
    
Only use this on handles that are not actively used anymore (e.g. program crashed) to prevent data corruption! Basically, it's almost always safer to just terminate the program instead. –  mafutrct Apr 14 '13 at 13:59

When using tools that forces file handles closed (like the previously-mentioned Unlocker), keep in mind that doing so might cause serious problems. (See this article by Raymond Chen.) Make sure you know which applications are using the file and that none of them are doing anything important.

It's safer to try shutting down the applications first instead of just forcing the handle closed.

share|improve this answer

I've had that happen to. Sometimes I can resolve the issue by deleting the contents first, then the folder(empty).

share|improve this answer
    
Yes - it worked for me! –  Wbdvlpr Jan 21 '13 at 13:04

This REG script will give you a "View Handles" right click context menu item which will invoke the Sysinternals handle utility to see all open handles to the file or folder that you right clicked on.

Put handle.exe from Sysinternals into a location that is accessible from your path.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Handle]
@="View &Handles"

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Handle\command]
@="cmd.exe /k handle -a -u \"%1\""
share|improve this answer

Unlocker and WhoLockMe don't work on 64-bit Windows. I use LockHunter.

share|improve this answer
    
Unlocker comes for 64-bit system. –  avirk Apr 14 '13 at 1:58

There's a native GUI for Windows:

Start>>All Programs>>Accessories>>System Tools>>Resource Monitor (or Run resmon.exe)

You can search for the "Associated Handles" using the searchbox (circled in red), and right click the process you want to end.


As an example, in the image below I could not delete my Eclipse directory. Searching for the Eclipse associated handles showed that the adb.exe had a handle to the directory. After ending the adb process, I could then delete the Eclipse directory.

enter image description here

share|improve this answer
    
This trick highlighted the process that was giving me grief :) –  Pure.Krome yesterday

When I was on XP I used WhoLockMe to find out what programs had files open and locked. The most recent version I could find doesn't mention Vista, but it'd be worth a shot.

Sometimes, you can delete it from the inside out manually. Just navigate all the way down in the hierarchy, delete all files, move up a directory, and repeat. Not sure why Windows can't do this itself, but it sometimes works for me.

share|improve this answer

The quickest and simplest approach is to use Handle, as mentioned by slolife, rather than using Process Explorer. They're both from Mark Russinovich @ Microsoft.

Don't be surprised to find that explorer.exe is the culprit, as I did today. Apparently there is an official way to restart explorer.exe, but I seem to be getting away with killing it and starting it back up again it in Task Manager.

share|improve this answer

If by “not in use”, you mean there are no open handles to it, then make sure that the Application Experience service is not disabled. If so, set it to manual:

Run dialog (or command prompt):

  sc config AeLookupSvc start= demand
share|improve this answer

I use Handle from SysInternals (now Microsoft). You can type in part of the folder name to see which process has a handle on that folder and then kill the handle.

Like others have mentioned, killing the handle can cause serious problems.

share|improve this answer

Try Ctrl + Shift + Esc > "programs", then right click the one you want to deactivate and choose deactivate. Then delete it again!

(My OS is in Swedish so the translations might not be exactly the same! but you get it!)

share|improve this answer

I've had the same problem with a memory flash (16 gb - irrelevant probably) and it wouldn't let me delete a folder. I tried every -freaking- solution found on internet (hiding thumbnails, deleting the folder from the cmd prompt with explorer.exe shut down, everything..) and nothing worked. What made it work? Well, this:

  1. Select all the files inside the folder
  2. Right click on them and select "Cut"
  3. Go back to the root folder
  4. Paste them
  5. Delete them

That worked just fine for me. Hope I helped. :-)

share|improve this answer

oft times the handle that is locked is internet explorer, i either close it in task manager, then delete the file or folder or close explorer...often a folder has a txt file that is open and that will be the handle that won't let u delete folders/files...just close the txt file and then u should be fine, u can now delete ur folder.

share|improve this answer
    
Why would IE lock local files and why .txt? –  gronostaj Aug 25 '13 at 14:06

go into the folder all the way down to the file or files being executed. when you try to delete this file it will give you what process it is running . write that down, then go to the task manager and end that process .. after that you can delete the folder.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.