예제 #1
0
        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);
        }
예제 #2
0
 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]);
         }
     }
 }
예제 #3
0
        public static bool Contains(string directoryPath, string searchPattern, bool isSearchChild)
        {
            bool result;

            try
            {
                string[] fileNames = DirFileHelper.GetFileNames(directoryPath, searchPattern, true);
                if (fileNames.Length == 0)
                {
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(result);
        }