SuperTeone
Programmer
Thanks for your tips, but I use absolute paths and full control directories (to everyone), so... the problem must be something different
And, for Jerry, voila' the code:
void RemoveDirectory(CString path)
// path contains the absoulute path of directory
int morefiles=1,err;
char strpath[128];
CString str,rmstr;
HANDLE hfind;
WIN32_FIND_DATA datafind;
str=path+"/*";
hfind=FindFirstFile(LPCTSTR(str),&datafind);
//start to find files in the directory
while(hfind!=INVALID_HANDLE_VALUE && morefiles!=0)
{
if (strcmp(datafind.cFileName,"."!=0 &&
strcmp (datafind.cFileName,".."!=0)
{
// Remove all files in the directory exept . and ..
rmstr=path+"/"+datafind.cFileName;
err=remove(rmstr);
}
morefiles=FindNextFile(hfind,&datafind);
}
strcpy(strpath,LPCTSTR(path));
err=_rmdir(strpath); // DOESN'T WORK!!!!
And, for Jerry, voila' the code:
void RemoveDirectory(CString path)
// path contains the absoulute path of directory
int morefiles=1,err;
char strpath[128];
CString str,rmstr;
HANDLE hfind;
WIN32_FIND_DATA datafind;
str=path+"/*";
hfind=FindFirstFile(LPCTSTR(str),&datafind);
//start to find files in the directory
while(hfind!=INVALID_HANDLE_VALUE && morefiles!=0)
{
if (strcmp(datafind.cFileName,"."!=0 &&
strcmp (datafind.cFileName,".."!=0)
{
// Remove all files in the directory exept . and ..
rmstr=path+"/"+datafind.cFileName;
err=remove(rmstr);
}
morefiles=FindNextFile(hfind,&datafind);
}
strcpy(strpath,LPCTSTR(path));
err=_rmdir(strpath); // DOESN'T WORK!!!!