Пример #1
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]);
         }
     }
 }
Пример #2
0
 public static string[] GetFileNames(string directoryPath, string searchPattern, bool isSearchChild)
 {
     if (!DirFileHelper.IsExistDirectory(directoryPath))
     {
         throw new FileNotFoundException();
     }
     string[] files;
     try
     {
         if (isSearchChild)
         {
             files = Directory.GetFiles(directoryPath, searchPattern, SearchOption.AllDirectories);
         }
         else
         {
             files = Directory.GetFiles(directoryPath, searchPattern, SearchOption.TopDirectoryOnly);
         }
     }
     catch (IOException ex)
     {
         throw ex;
     }
     return(files);
 }