1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
private static void (string location) { if(!Directory.Exists(location)) return; if (Directory.GetDirectories(location).Length != 0) { var subDirs = Directory.GetDirectories(location); foreach (var subDir in subDirs) { DeleteEmptyFolders(subDir); } } if (IsFolderEmpty(location) && location != RootPath) { Console.WriteLine($"Delete location: {location}"); Directory.Delete(location); return; } }
private static bool IsFolderEmpty(string folderLocation) { if (Directory.Exists(folderLocation)) { var filesAndFolders = Directory.GetFileSystemEntries(folderLocation); return filesAndFolders.Length == 0 ? true : false; }
return true; }
|
近期评论