?
Solved

Can't delete empty directory

Posted on 1998-02-13
2
Medium Priority
?
604 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

777 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