Solved

Can't delete empty directory

Posted on 1998-02-13
2
596 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
2 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 50 total points
Comment Utility
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
Comment Utility
Thanks, I was closing the FindFile handle at the wrong place.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now