There are lots of examples of recursive file searches around so I'm not going to post another one. If you use the DirectoryInfo and FileInfo classes, a FileInfo with a Length of zero indicates an empty file. You can call GetDirectories and GetFiles on a DirectoryInfo to get an array of directories and files. If both have a Length of zero then the folder is empty. Both classes have a Delete method.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.