function DeletePath(mDirName: string): Boolean; { 返回删除指定目录是否成功 }
var
vSearchRec: TSearchRec;
vPathName: string;
K: Integer;
begin
Result := True;
vPathName := mDirName + '/*.*';
K := FindFirst(vPathName, faAnyFile, vSearchRec);
while K = 0 do begin
if (vSearchRec.Attr and faDirectory > 0) and
(Pos(vSearchRec.Name, '..') = 0) then begin
FileSetAttr(mDirName + '/' + vSearchRec.Name, faDirectory);
Result := DeletePath(mDirName + '/' + vSearchRec.Name);
end else if Pos(vSearchRec.Name, '..') = 0 then begin
FileSetAttr(mDirName + '/' + vSearchRec.Name, 0);
Result := DeleteFile(PChar(mDirName + '/' + vSearchRec.Name));
end;
if not Result then Break;
K := FindNext(vSearchRec);
end;
FindClose(vSearchRec);
Result := RemoveDir(mDirName);
end;