Forum Discussion

khun's avatar
khun
New Contributor
6 years ago
Solved

DeleteFolder doesn't work

Hi!

 

We try this (with TC 12.6) to empty a temporary folder with testdata before running each test:

 

if aqFileSystem.Exists(Spath):
   aqFileSystem.DeleteFolder(Spath, True)

 

but TestComplete gives an error and the log says:

 

The directory is not empty.
 
If the directory _is_ empty, then it is deleted. But the True parameter should delete the folder no matter what. At least that is how I read the documentation...
 
Thanks for any help!
  • OK, so someone else in the company just found the problem: if the folder is open in e.g. Windows Explorer, you get this message! All files and folders in the folder are deleted, but the folder itself is not. And TC gives an error about the folder not being empty.

     

2 Replies

  • khun's avatar
    khun
    New Contributor

    OK, so someone else in the company just found the problem: if the folder is open in e.g. Windows Explorer, you get this message! All files and folders in the folder are deleted, but the folder itself is not. And TC gives an error about the folder not being empty.

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Right... because the folder is, technically, in use and the file system won't allow you to delete the object while it's in use.