void DeleteEmptyFolders(string parentFolder)
{
var dir = new DirectoryInfo(parentFolder);
var subdirs = dir.GetDirectories("*.*", SearchOption.AllDirectories);
foreach (var subdir in subdirs)
{
if (!Directory.Exists(subdir.FullName)) continue;
var subFiles = subdir.GetFileSystemInfos("*.*", SearchOption.AllDirectories);
var findFile = false;
foreach (var sub in subFiles)
{
findFile = (sub.Attributes & FileAttributes.Directory) == 0;
if(findFile) break;
}
if (!findFile) subdir.Delete(true);
}
}