//---------------删除目录树------------------------------------------------
FUNCTION FkDeleteTree(vFolder:STRING):Boolean;
VAR
srList: TSearchRec;
DirList: TStringList;
oFound,oTemp: Boolean;
i: integer;
BEGIN
oTemp:=True;
// 建立一个文件夹列表
DirList := TStringList.Create;
vFolder:=TRIM(vFolder);
IF vFolder[length(vFolder)]<>'/' THEN vFolder:=vFolder + '/';
// 生成文件夹列表
oFound:=FindFirst(vFolder+'*.*',(faDirectory+faHidden+faSysFile), srList) = 0;
WHILE oFound DO
BEGIN
IF (DirectoryExists(vFolder+srList.Name) and (srList.Name<>'.') AND (srList.Name<>'..')) THEN
DirList.Add(vFolder+srList.Name);
oFound :=(FindNext(srList)=0);
END;
FindClose(srList);
//查找当前目录的文件删除
oFound:=FindFirst(vFolder+'*.*',(faAnyFile+faHidden+faSysFile+faReadOnly), srList) = 0;
WHILE oFound DO
BEGIN
FileSetAttr(vFolder+srList.Name,0);
oTemp:=DeleteFile(vFolder+srList.Name) and oTemp;
oFound:=(FindNext(srList)=0);
END;
FindClose(srList);
//查找列表的子目录
FOR i := 0 TO DirList.Count-1 DO FkDeleteTree(DirList);
FileSetAttr(vFolder,0);
oTemp:=RemoveDir(vFolder) AND oTemp;
DirList.Free;
Result:=oTemp;
END;
//--------------------------------------------------------------
//--------------删除指定目录中的所有文件--------------------
FUNCTION FkDeleteAllFile(vFolder:STRING):Boolean;
VAR
srList: TSearchRec;
oFound,oTemp: Boolean;
i: integer;
BEGIN
oTemp:=True;
// 建立一个文件夹列表
DirList := TStringList.Create;
vFolder:=TRIM(vFolder);
IF vFolder[length(vFolder)]<>'/' THEN vFolder:=vFolder + '/';
//查找当前目录的文件删除
oFound:=FindFirst(vFolder+'*.*',(faAnyFile+faHidden+faSysFile+faReadOnly), srList) = 0;
WHILE oFound DO
BEGIN
FileSetAttr(vFolder+srList.Name,0);
oTemp:=DeleteFile(vFolder+srList.Name) and oTemp;
oFound:=(FindNext(srList)=0);
END;
FindClose(srList);
//查找列表的子目录
Result:=oTemp;
END;