Je programme sous C++, MFC, windows.Comment supprimer le dossier dans la corbeille
Je souhaite supprimer un dossier dans la corbeille. Comment puis-je faire cela?
CString filePath = directorytoBeDeletePath;
TCHAR ToBuf[MAX_PATH + 10];
TCHAR FromBuf[MAX_PATH + 10];
ZeroMemory(ToBuf, sizeof(ToBuf));
ZeroMemory(FromBuf, sizeof(FromBuf));
lstrcpy(FromBuf, filePath);
SHFILEOPSTRUCT FileOp;
FileOp.hwnd = NULL
FileOp.wFunc=FO_DELETE;
FileOp.pFrom=FromBuf;
FileOp.pTo = NULL;
FileOp.fFlags=FOF_ALLOWUNDO|FOF_NOCONFIRMATION;
FileOp.hNameMappings=NULL;
bRet=SHFileOperation(&FileOp);
Une erreur avec le code ci-dessus? Il a toujours échoué.
Je trouve le problème: filePath devrait être: "c: \ abc" et non "c: \ abc \"
Merci beaucoup ~~~~ – user25749