Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Can't delete empty directory

Posted on 1998-02-13
2
Medium Priority
?
606 Views
Last Modified: 2013-12-03
I've created a function that will delete recursively a directory tree; well that is what it is suppose to do. I am able to delete all the files within the directoy tree but I cannot delete the directories.

Here is the part of the code that is not working:

/* First I store the address\name of the current directory*/
CurrentDir=FileInfo->cFileName;            

/* Then I set that directory as the current directory to search recursively*/
SetCurrentDirectory(FileInfo->cFileName);

/* Recursive function that deletes the files and directories under the current directory*/
SearchDirectory(FileInfo);

/* After it returns I go back to the previous directory */                              
SetCurrentDirectory("..");

/* Then I attempt to delete the directory */
RemoveDirectory(CurrentDir.GetBuffer(1))


The RemoveDirectory() function returns an:

ERROR_SHARING_VIOLATION

after I use GetLastError.


Is it that the directoy remains opened?

0
Comment
Question by:santamaria
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 200 total points
ID: 1411239
Either that directory is the current directory for your process, or it is the current directory for some other process.  _any_ other process having a directory as the process current directory will prevent that directory from being deleted.

Check everything: the exploer, services, remote users logged into your machine.

Also, it's possible that you still have a file find handle open that's watching that directory. You didn't post all of your code, so I can't be more certain about that possibility.

.B ekiM


0
 

Author Comment

by:santamaria
ID: 1411240
Thanks, I was closing the FindFile handle at the wrong place.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question