procedure m_deltree(filepath: TFileName);
var
tfileinfo: TSearchRec;
r: TFileName;
retcode: longint;
atribute: word;
begin
r := filepath + '\*.*';
writeln(r);
retcode := FindFirst(r, faAnyFile - faVolumeID, tfileinfo);
while retcode = 0 do
begin
if (tfileinfo.attr and faDirectory = faDirectory) then
begin
if (tfileinfo.name <> '.') and (tfileinfo.name <> '..') then
m_deltree(filepath + '\' + tfileinfo.name)
end
else
begin
atribute := tfileinfo.attr;
atribute := atribute and not faReadOnly;
atribute := atribute and not faArchive;
atribute := atribute and not faSysFile;
atribute := atribute and not faHidden;
FileSetAttr(filepath + '\' + tfileinfo.name, atribute);
if DeleteFile(filepath + '\' + tfileinfo.name) = false then
writeln('Error deleting ', filepath + '\' + tfileinfo.name);
end;
retcode := FindNext(tfileinfo);
end;
FindClose(tfileinfo);
atribute := FileGetAttr(filepath);
atribute := atribute and not faReadOnly;
atribute := atribute and not faArchive;
atribute := atribute and not faSysFile;
atribute := atribute and not faHidden;
FileSetAttr(filepath, atribute);
if RemoveDir(filepath) = false then
writeln('Error removing ', filepath);
end;