After successfully deleting all files, the uninstaller tries to delete the remaining empty directories. The deletion algorithm is the search for paths of directories by recursion with FindFirstFile / FindNextFile and writing them to the vector of strings, after which deleting directories by paths from the end of the vector with error handling. When developing the application, the picture is as follows: Listing of the uninstaller

It turns out that only the child empty directories are deleted, and as soon as the cycle reaches their parent, it responds with error 145 (the directory is not empty), although it is clear from the listing that all descendants have been deleted. And the root directory is generally occupied by another process (error 32). I repeat - all directories are pre-cleared of files. It turns out that the operation of deleting a directory is deferred and deletion takes place after the application is closed. When restarting the uninstaller, only the last empty folders are deleted again. Use in the right places CloseHandle and / or FlushFileBuffers did not produce any result. The question is how to get the uninstaller to delete directories instantly, without waiting for the application to close?

PS: the uninstaller works from another independent directory

  • FindCloseFile is called? - Anton Shchyrov
  • No, of course ... I'll try now - Iceman
  • Sorry, FindClose() - Anton Shchyrov
  • Something I do not understand where to call it. I call if (FileName! = ".." && FileName! = ".") Before recursion - not all files are deleted and code 145 still occurs - Iceman
  • It is necessary to call at the end of the FindFirstFile / FindNextFile for each error-free call FindFirstFile should be a call to FindClose() - Anton Shchyrov

0