Удаление папки со всем содержимым
Как удалить не пустой каталог?
function MyRemoveDir(sDir : string) : Boolean; var iIndex: Integer; SearchRec: TSearchRec; sFileName: string; begin Result := False; 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 MyRemoveDir(sFileName); end else begin if SearchRec.Attr <> faArchive then FileSetAttr(sFileName, faArchive); if not DeleteFile(sFileName) then ShowMessage('Could NOT delete ' + sFileName); end; iIndex := FindNext(SearchRec); end; FindClose(SearchRec); RemoveDir(ExtractFileDir(sDir)); Result := True; end;