核心提示:procedure RemoveEmptyFolders(const rootFolder : string) ;var fd: TWin32FindData; h: THandle; rf: str...
procedure RemoveEmptyFolders(const rootFolder : string) ;var
fd: TWin32FindData;
h: THandle;
rf: string;
begin
rf := IncludeTrailingBackslash(rootFolder) ;
h := FindFirstFile(PChar(rf + '*.*'), fd) ;
if h <> INVALID_HANDLE_VALUE then
try
with fd do
repeat
if (dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY > 0) and (Pos(cFileName,'.;..') = 0) then
begin
if not RemoveDir(rf + cFilename) then RemoveEmptyFolders(rf + cFileName) ;
end;
until not FindNextFile(h,fd) ;
finally
Windows.FindClose(h) ;
end;
end;