Удаление каталогов

Советы » Каталоги » Удаление каталогов

Функция удаляет временные каталоги.


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

;

Другое по теме:

Категории

Статьи

Советы

Copyright © 2022 - All Rights Reserved - www.delphirus.com