Example #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);
        }
Example #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]);
         }
     }
 }