Created directory is locked by explorer.exe, can't delete it
-
reptor
- Ogre Magi
- Posts: 1120
- Joined: Wed Nov 15, 2006 7:41 pm
- Location: Finland
- x 5
Created directory is locked by explorer.exe, can't delete it
Hi
I just ran into a weird problem I've never seen before.
I use Windows XP Home SP3. F-Secure firewall & anti-virus. Recently re-installed and should be a fairly clean system, not much programs installed.
I am developing a console program (C++) which opens a package file, reads its contents, and writes out its contents into a directory which has the basename (extension dropped) of the package file as its name.
I am using boost::filesystem::create_directory to create the directory if it doesn't exist.
Now, what happened is that after I ran the program with a certain package file as input, it created the directory just fine - empty one this time because I was just testing. But the problem is that I can't delete the directory through explorer or through console. Windows says that the directory is in use by some process.
The name of this directory is BMP2. Other package files which have different names don't have the problem, I can delete their directories just fine.
I carefully checked that this program that created the directory is not running anymore, so it can't be the one that is preventing the deletion of the directory. The program exits normally and does everything just like I want.
I checked which process is using the directory by using Process Explorer (sysinternals/microsoft), and it says that explorer.exe is using the directory. Then I close the file manager, console, visual studio, and the directory is still in use by explorer.exe and it still can't be deleted of course.
What can cause this? Is this a Windows XP bug, or perhaps caused by anti-virus program? Or by something else?
What I am going to do next is to reboot my computer and see if the problem goes away. I expect it to go away.
But anyways I would like to hear what can possibly cause this problem and if there are anything that I can do to prevent it from happening, and why it happened for that one directory named BMP2 but not for the others.
I just ran into a weird problem I've never seen before.
I use Windows XP Home SP3. F-Secure firewall & anti-virus. Recently re-installed and should be a fairly clean system, not much programs installed.
I am developing a console program (C++) which opens a package file, reads its contents, and writes out its contents into a directory which has the basename (extension dropped) of the package file as its name.
I am using boost::filesystem::create_directory to create the directory if it doesn't exist.
Now, what happened is that after I ran the program with a certain package file as input, it created the directory just fine - empty one this time because I was just testing. But the problem is that I can't delete the directory through explorer or through console. Windows says that the directory is in use by some process.
The name of this directory is BMP2. Other package files which have different names don't have the problem, I can delete their directories just fine.
I carefully checked that this program that created the directory is not running anymore, so it can't be the one that is preventing the deletion of the directory. The program exits normally and does everything just like I want.
I checked which process is using the directory by using Process Explorer (sysinternals/microsoft), and it says that explorer.exe is using the directory. Then I close the file manager, console, visual studio, and the directory is still in use by explorer.exe and it still can't be deleted of course.
What can cause this? Is this a Windows XP bug, or perhaps caused by anti-virus program? Or by something else?
What I am going to do next is to reboot my computer and see if the problem goes away. I expect it to go away.
But anyways I would like to hear what can possibly cause this problem and if there are anything that I can do to prevent it from happening, and why it happened for that one directory named BMP2 but not for the others.
- jacmoe
- OGRE Retired Moderator

- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Do you have any shell extensions running, like TortoiseSVN?
If so, kill the TortoiseSVNCache process.
It fixed similar problems for me.
Or it could be that your new windows installation doesn't see the file/folder permissions on your programming drive(s).
Check permissions.
If you have a GUID instead of a user, you need to take ownership again.
Let me know if I didn't explain properly.
If so, kill the TortoiseSVNCache process.
It fixed similar problems for me.
Or it could be that your new windows installation doesn't see the file/folder permissions on your programming drive(s).
Check permissions.
If you have a GUID instead of a user, you need to take ownership again.
Let me know if I didn't explain properly.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- PolyVox
- OGRE Contributor

- Posts: 1316
- Joined: Tue Nov 21, 2006 11:28 am
- Location: Groningen, The Netherlands
- x 18
- Contact:
Well you could try Unlocker although personally I never got it to work (but maybe I'm just doing something wrong).
Otherwise try rebooting into safe mode?
Or maybe use a Linux live CD or some such thing to reboot and delete it from there?
Otherwise try rebooting into safe mode?
Or maybe use a Linux live CD or some such thing to reboot and delete it from there?
- Thieum
- Gnome
- Posts: 342
- Joined: Wed Apr 26, 2006 5:13 pm
- Location: Bordeaux, France
- x 2
- Contact:
you can close the handles directly from process explorer :
1 - search for the open directory in procexp
2 - doubleclick on the open occurrences, this will highlight the handle in the owner's process handle list
3 - right clic on the handle and close it
you may now delete the directory
This is a problem i am often encountering. it is really annoying but I haven't found a better solution than manually closing the open handles
1 - search for the open directory in procexp
2 - doubleclick on the open occurrences, this will highlight the handle in the owner's process handle list
3 - right clic on the handle and close it
you may now delete the directory
This is a problem i am often encountering. it is really annoying but I haven't found a better solution than manually closing the open handles
-
reptor
- Ogre Magi
- Posts: 1120
- Joined: Wed Nov 15, 2006 7:41 pm
- Location: Finland
- x 5
No TortoiseSVN or anything like that. By the way I stopped using TortoiseSVN because it slowed down the file manager quite a lot.
It is not a permissions issue. It is an NTFS partition. But I can create & delete other files in the same directory just fine, this one subdirectory only is problematic. And it was created as the same user that tries to delete it.
Windows clearly says that the problem is that the directory is in use, it does not complain about permissions. Or actually (I translate from Finnish) it says that there is a "shared usage problem" and that the directory "can be in use". And as I said, Process Explorer says that explorer.exe is using the directory.
I'll reboot next and then report back here if that solves the problem.
Edit: OK, I'll try first what Thieum suggests. No reboots done yet.
It is not a permissions issue. It is an NTFS partition. But I can create & delete other files in the same directory just fine, this one subdirectory only is problematic. And it was created as the same user that tries to delete it.
Windows clearly says that the problem is that the directory is in use, it does not complain about permissions. Or actually (I translate from Finnish) it says that there is a "shared usage problem" and that the directory "can be in use". And as I said, Process Explorer says that explorer.exe is using the directory.
I'll reboot next and then report back here if that solves the problem.
Edit: OK, I'll try first what Thieum suggests. No reboots done yet.
-
reptor
- Ogre Magi
- Posts: 1120
- Joined: Wed Nov 15, 2006 7:41 pm
- Location: Finland
- x 5
When trying to close it from Process Explorer, it says "Error opening process: kahva ei kelpaa" in which "kahva ei kelpaa" is roughly said "handle is invalid". And the directory still can't be deleted.
I try as admin user next to do the same.
Edit #1: OK it worked as admin user. So I started Process Explorer as admin and did what Thieum suggests, and after that I can delete the directory normally in file manager as normal user. It is now deleted.
Edit #2: Now I ran my program by giving it the same package file as input. It created the directory but the difference this time was that I could delete the directory normally.
It is still a mystery what caused the problem. Thieum, do you have any idea what could be the reason why it happens? Do we have the same operating system? Same anti-virus?
I try as admin user next to do the same.
Edit #1: OK it worked as admin user. So I started Process Explorer as admin and did what Thieum suggests, and after that I can delete the directory normally in file manager as normal user. It is now deleted.
Edit #2: Now I ran my program by giving it the same package file as input. It created the directory but the difference this time was that I could delete the directory normally.
It is still a mystery what caused the problem. Thieum, do you have any idea what could be the reason why it happens? Do we have the same operating system? Same anti-virus?
- Thieum
- Gnome
- Posts: 342
- Joined: Wed Apr 26, 2006 5:13 pm
- Location: Bordeaux, France
- x 2
- Contact:
- twilight17
- Goblin
- Posts: 297
- Joined: Thu Aug 23, 2007 3:47 am
- x 1
Unlocker is great - sometimes the same thing happens to me, all I have to do is right click the File or Folder->UnlockerPolyVox wrote:Well you could try Unlocker although personally I never got it to work (but maybe I'm just doing something wrong).
then choose delete and hit Unlock All!
Great software ;D
- PolyVox
- OGRE Contributor

- Posts: 1316
- Joined: Tue Nov 21, 2006 11:28 am
- Location: Groningen, The Netherlands
- x 18
- Contact:
Well I'd like to agree, but actually I right clicked on the folder, selected unlocker from the context menu, and nothing happened. I was expecting a popup window or something?twilight17 wrote:Unlocker is great - sometimes the same thing happens to me, all I have to do is right click the File or Folder->Unlocker
then choose delete and hit Unlock All!
Great software ;D
- twilight17
- Goblin
- Posts: 297
- Joined: Thu Aug 23, 2007 3:47 am
- x 1
