Forum Discussion

aa1's avatar
aa1
Contributor
5 years ago
Solved

Deleting folders does not work

Hi, I am trying to delete a folder from my local directory. The following piece of code seems to run for the first two or one folders and then it crashes. I cannot seem to  understand what is wrong. ...
  • tristaanogre's avatar
    5 years ago

    I think the problem is that if FindFolders doesn't find anything, it doesn't return a collection at all but a "null" value.  The code you shold use is, instead of  

     

     if (foldersToDelete.Count > 0)

    replace with 

     

    if (foldersToDelete != null)
  • AlexKaras's avatar
    AlexKaras
    5 years ago

    Hi,

     

    I think Robert is correct. .Count is not a property of the result returned by .FindFolders() method. Refer to the code sample provided in the documentation for this method.