//我也来up
//清空一个目录
function EmptyDirectory(TheDirectory :String ; Recursive : Boolean):Boolean;stdcall;export;
var
SearchRec : TSearchRec;
Res : Integer;
begin
Result := False;
TheDirectory := Trim(TheDirectory);
if copy(TheDirectory,Length(TheDirectory),1)<>'\' then
TheDirectory :=TheDirectory+'\';
Res := FindFirst(TheDirectory + '*.*', faAnyFile, SearchRec);
try
while Res = 0 do
begin
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
begin
if ((SearchRec.Attr and faDirectory) > 0) and Recursive then
begin
EmptyDirectory(TheDirectory + SearchRec.Name, True);
RemoveDirectory(PChar(TheDirectory + SearchRec.Name));
end
else
begin
DeleteFile(PChar(TheDirectory + SearchRec.Name))
end;
end;
Res := FindNext(SearchRec);
end;
Result := True;
finally
FindClose(SearchRec);
end;
end;
procedure makedir(modulname,pathname,dirname,filepath:string);
begin
try
if not directoryexists(frootpath+modulname) then
createdir(FRootPath+modulname);
if not DirectoryExists(FRootPath+modulname+'\'+pathname) then
createdir(FRootPath+modulname+'\'+pathname);
if not directoryexists(FRootPath+modulname+'\'+pathname+'\'+dirname) then
createdir(FRootPath+modulname+'\'+pathname+'\'+dirname);
if filepath<>'' then
if not directoryexists(FRootPath+modulname+'\'+pathname+'\'+dirname+'\'+filepath) then
createdir(FRootPath+modulname+'\'+pathname+'\'+dirname+'\'+filepath)
except
On E:Exception do begin
abort;
end;
end;
删:RemoveDir