deleting folders and contents

Started by
2 comments, last by supagu 19 years, 7 months ago
im trying to delete a folder and its contents: using _chdir to change the directory, and rmdir to remove the directory(once i have emptied the files in it). What i do is to find all files/folders i na directory, delete the files, then go into the folder and do the same thing recursively, this deletes the files perfectly well, but when i try to delete the folders, windows wont let me, i get an error saying the directory is in use, now i have determined if i dont go into the folder with _chdir and then go back out to delete the folder, windows doesnt like it, is there some way i have to release handles i get to folders via _chdir? has any one had this problem and found a solution?
Advertisement
use DOS commands with the system() function. it accepts a string as it's arguement so you'd want to compile the filename into a string then parse it through system(), i think it only accepts c style char array strings though so use the member function c_str() or wahtever it is to convert it. if useing the stl string class;
| Member of UBAAG (Unban aftermath Association of Gamedev)
If you're using FindFirstFile/FindNextFile, make sure you actually close the find handle by using FindClose. The open find handle will keep the directory in use.
Kippesoep
i use _findfirst, i was wondering if i had to release the handles... and yep, thats the problem had to release handles with
_findclose

thx guys

[Edited by - supagu on September 12, 2004 11:27:50 PM]

This topic is closed to new replies.

Advertisement