antp Super Administrateur Champion des excuses bidons | Faut supprimer tous les fichiers, y a rien de prévu dans l'OS pour faire autrement
Code :
- function Deltree(sDir: string): Boolean;
- var
- iIndex: Integer;
- SearchRec: TSearchRec;
- sFileName: string;
- begin
- sDir := sDir + '\*.*';
- iIndex := FindFirst(sDir, faAnyFile, SearchRec);
- while iIndex = 0 do
- begin
- sFileName := ExtractFileDir(sDir) + '\' + SearchRec.Name;
- if SearchRec.Attr = faDirectory then
- begin
- if (SearchRec.Name <> '' ) and
- (SearchRec.Name <> '.') and
- (SearchRec.Name <> '..') then
- Deltree(sFileName);
- end else
- begin
- if SearchRec.Attr <> faArchive then
- FileSetAttr(sFileName, faArchive);
- DeleteFile(sFileName);
- end;
- iIndex := FindNext(SearchRec);
- end;
- FindClose(SearchRec);
- RemoveDir(ExtractFileDir(sDir));
- Result := True;
- end;
|
|