procedure TForm1.DeleteFolder(psDelPath: string);
var
loSr: TSearchRec;
begin
if FindFirst(psDelPath + '/*.*', faAnyFile, loSr) = 0 then
begin
if loSr.Attr <> faDirectory then
DeleteFile(psDelPath + '/' + loSr.Name)
else
begin
if (loSr.Name <> '.') and (loSr.Name <> '..') then
begin
DeleteFolder(psDelPath + '/' + loSr.Name);
end;
end;
while FindNext(loSr) = 0 do
begin
if loSr.Attr <> faDirectory then
begin
DeleteFile(psDelPath + '/' + loSr.Name);
end
else if (loSr.Name <> '.') and (loSr.Name <> '..') then
begin
DeleteFolder(psDelPath + '/' + loSr.Name);
end;
end;
FindClose(loSr);
end;
RemoveDirectory(PChar(psDelPath));
end;