Well, it's not pretty, but here's the code (
hennep may well recognise some of the nifty footwork done with the ffblk to find directories...)
list<string> full_dir;
list<string> full_file;
ffblk ffblk;
Screen->Cursor=crHourGlass;
string olddir=listLocalDir->Directory.c_str();
string targetdir=(olddir[olddir.length()-1]=='\\')?olddir

lddir+"\\";
targetdir+=listLocalDir->Items->Strings[listLocalDir->ItemIndex].c_str();
if(!DirectoryExists(targetdir.c_str())){
targetdir=olddir;
}
// get all local directories and files
full_dir.push_back(targetdir);
list<string>::iterator iter=full_dir.begin();
while(iter!=full_dir.end()){
string& p_i=*iter;
string filter=p_i+"\\*";
int result=findfirst(filter.c_str(),&ffblk,FA_DIREC);
while(!result){
if((ffblk.ff_attrib & FA_DIREC)==FA_DIREC){
string dir=ffblk.ff_name;
if(dir!="." && dir!=".."

{
string fulldir=p_i+"\\";
fulldir+=dir;
full_dir.push_back(fulldir);
}
}
result=findnext(&ffblk);
}
filter=p_i+"\\*.*";
result=findfirst(filter.c_str(),&ffblk,FA_ARCH);
while(!result){
string fullfile=p_i+"\\";
fullfile+=ffblk.ff_name;
full_file.push_back(fullfile);
result=findnext(&ffblk);
}
iter++;
}
//delete all files
iter=full_file.begin();
while(iter!=full_file.end()){
string& p_i=*iter;
if(remove(p_i.c_str())){
string msg="Failed to delete file \"";
msg+=p_i+"\"";
ShowMessage(msg.c_str());
Screen->Cursor=crDefault;
return;
}
iter++;
}
//delete all folders
full_dir.reverse();
iter=full_dir.begin();
while(iter!=full_dir.end()){
string& p_i=*iter;
if(!RemoveDir(p_i.c_str())){
string msg="Failed to delete directory \"";
msg+=p_i+"\"";
ShowMessage(msg.c_str());
Screen->Cursor=crDefault;
return;
}
iter++;
}
listLocalDir->Update();
listLocalFiles->Update();
Screen->Cursor=crDefault;
It is the last section that deletes the folder(s), and that always fails in NT (and sometimes 98).
If this is too ugly a clump of code, I could try to refine it to essentials, but I wanted to give an idea of the processes that are taking place.
& thanks alot for your ongoing help!
Cheers,
Douglas JL
Common sense is what tells you the world is flat.