For Each Child As FolderItem In Folder.Children
Child.Delete
Next
Is this safe? I know using indexes to work backwards of course. But using an iterator, would files still be skipped? Would deleting files change the iterator contents and throw an exception somewhere?
Just curious. I’m going to do it the old fashioned way because I’m too lazy to test it.
Interesting question for which I don’t have an answer, but I wanted to point out you have to watch out for aliases and symbolic links that may delete unwanted items.
For Each Child As FolderItem In Folder.Children(False)
Child.Delete
Next
I would add the (false) which means TrueFolderItem in API1 because without (False), then with (True), if you have alias in your folder, you won’t remove it but its target.
for me it works at 2020r2.1 and linux.
because i had the need for deleting older data from security cam i made a method even
and it runs fine with for each and .Remove