suppression d'un répertoire non vide
bonjour,
j'aimerai supprimé un répertoire entier.
J'ai trouvé une explication sur ce lien :
http://cpp.developpez.com/faq/vc/?pa...EmptyDirectory
mais ca ne marche pas :cry: est-ce que j'ai fais une erreur?
mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
CString repertoire= "C:\\Temp\\program files";
bool supressionDefinitive= false;
if (PathFileExists(repertoire))
{
int s = strlen(repertoire);
TCHAR * rep = new TCHAR[strlen(repertoire)+2];
strcpy(rep, repertoire);
rep[strlen(repertoire)+1] = '\0';
SHFILEOPSTRUCT sh;
sh.hwnd = NULL;
sh.wFunc = FO_DELETE;
sh.pFrom = rep;
sh.pTo = NULL;
sh.fFlags = FOF_NOCONFIRMATION|FOF_SILENT;
if(!supressionDefinitive)
sh.fFlags |= FOF_ALLOWUNDO;
sh.fAnyOperationsAborted = FALSE;
sh.lpszProgressTitle = NULL;
sh.hNameMappings = NULL;
delete [] rep;
return (SHFileOperation(&sh)==0);
}
else
{
AfxMessageBox("dossier inexistant");
} |
merci