public static bool ClearDirectory(string fullPath, string[] fileExtensionFilter, string[] folderFilter) { bool result; try { if (fileExtensionFilter != null) { string[] files = Directory.GetFiles(fullPath); for (int i = 0; i < files.Length; i++) { if (fileExtensionFilter != null && fileExtensionFilter.Length > 0) { for (int j = 0; j < fileExtensionFilter.Length; j++) { if (files[i].Contains(fileExtensionFilter[j])) { CFileManager.DeleteFile(files[i]); break; } } } } } if (folderFilter != null) { string[] directories = Directory.GetDirectories(fullPath); for (int k = 0; k < directories.Length; k++) { if (folderFilter != null && folderFilter.Length > 0) { for (int l = 0; l < folderFilter.Length; l++) { if (directories[k].Contains(folderFilter[l])) { CFileManager.DeleteDirectory(directories[k]); break; } } } } } result = true; } catch (Exception) { result = false; } return(result); }