public static bool IsEmptyDirectory(string directoryPath) { bool result; try { string[] fileNames = DirFileHelper.GetFileNames(directoryPath); if (fileNames.Length > 0) { result = false; } else { string[] directoryNames = DirFileHelper.GetDirectories(directoryPath); if (directoryNames.Length > 0) { result = false; } else { result = true; } } } catch { result = true; } return(result); }
public static void ClearDirectory(string directoryPath) { if (DirFileHelper.IsExistDirectory(directoryPath)) { string[] fileNames = DirFileHelper.GetFileNames(directoryPath); for (int i = 0; i < fileNames.Length; i++) { DirFileHelper.DeleteFile(fileNames[i]); } string[] directoryNames = DirFileHelper.GetDirectories(directoryPath); for (int i = 0; i < directoryNames.Length; i++) { DirFileHelper.DeleteDirectory(directoryNames[i]); } } }
public static bool Contains(string directoryPath, string searchPattern) { bool result; try { string[] fileNames = DirFileHelper.GetFileNames(directoryPath, searchPattern, false); if (fileNames.Length == 0) { result = false; } else { result = true; } } catch (Exception ex) { throw new Exception(ex.Message); } return(result); }