ISCL is a Intelligent Information Consulting System. Based on our knowledgebase, using AI tools such as CHATGPT, Customers could customize the information according to their needs, So as to achieve

David Reed"s Entry for the Custom RemoveEmptyFolders Delphi Function

17
Question: David Reed's Entry for the Custom RemoveEmptyFolders Delphi Function

Challenge: a custom Delphi function, RemoveEmptyFolders, should take a path name (directory) and should remove / delete all empty sub-folders at any (sub) level.

The code is submitted for the RemoveEmptyFolders Delphi Challenge

Answer:

RemoveEmptyFolders entry by David Reed:

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;

Explore the list of all accepted entries for RemoveEmptyFolders Delphi challenge.
Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.