SearchDirectory() public static method

public static SearchDirectory ( string directory, string filemask ) : List
directory string
filemask string
return List
Example #1
0
 private static void SearchDirectory(string directory, string filemask, System.Collections.Generic.List <string> collection, bool searchSubDiretories, bool ignoreHidden)
 {
     try
     {
         bool     flag  = Regex.IsMatch(filemask, "^\\*\\..{3}$");
         string   b     = null;
         string[] files = System.IO.Directory.GetFiles(directory, filemask);
         if (flag)
         {
             b = filemask.Remove(0, 1);
         }
         string[] array = files;
         for (int i = 0; i < array.Length; i++)
         {
             string text = array[i];
             if ((!ignoreHidden || (System.IO.File.GetAttributes(text) & System.IO.FileAttributes.Hidden) != System.IO.FileAttributes.Hidden) && (!flag || !(System.IO.Path.GetExtension(text) != b)))
             {
                 collection.Add(text);
             }
         }
         if (searchSubDiretories)
         {
             string[] directories = System.IO.Directory.GetDirectories(directory);
             string[] array2      = directories;
             for (int j = 0; j < array2.Length; j++)
             {
                 string text2 = array2[j];
                 if (!ignoreHidden || (System.IO.File.GetAttributes(text2) & System.IO.FileAttributes.Hidden) != System.IO.FileAttributes.Hidden)
                 {
                     FileUtility.SearchDirectory(text2, filemask, collection, searchSubDiretories, ignoreHidden);
                 }
             }
         }
     }
     catch (System.UnauthorizedAccessException)
     {
     }
 }
Example #2
0
 public static System.Collections.Generic.List <string> SearchDirectory(string directory, string filemask)
 {
     return(FileUtility.SearchDirectory(directory, filemask, true, true));
 }
Example #3
0
 public static System.Collections.Generic.List <string> SearchDirectory(string directory, string filemask, bool searchSubdirectories, bool ignoreHidden)
 {
     System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
     FileUtility.SearchDirectory(directory, filemask, list, searchSubdirectories, ignoreHidden);
     return(list);
 }