Ejemplo n.º 1
0
		public static void RecursiveListFilesHelper(FilePath dir, FileFilter filter, IList<FilePath> fileList)
		{
			foreach (FilePath f in dir.ListFiles())
			{
				if (f.IsDirectory())
				{
					RecursiveListFilesHelper(f, filter, fileList);
				}
				else
				{
					if (filter.Accept(f))
					{
						fileList.Add(f);
					}
				}
			}
		}
Ejemplo n.º 2
0
 public static String[] ListFilesInDirectoryByFilter(String path, bool recursive, FileFilter filter)
 {
     if (!String.IsNullOrEmpty(path))
     {
         DirectoryInfo dir = new DirectoryInfo(path);
         if (dir.Exists)
         {
             FileInfo[] files = dir.GetFiles("*.*", recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
             String[]   list  = new String[files.Length];
             for (int i = 0; i < files.Length; i++)
             {
                 if (filter.Accept(files[i].Name))
                 {
                     list[i] = files[i].FullName;
                 }
             }
             return(list);
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
 public FilePath[] ListFiles(FileFilter filter)
 {
     try
     {
         if (IsFile())
         {
             return(null);
         }
         List <FilePath> list = new List <FilePath>();
         foreach (string filePath in Directory.GetFileSystemEntries(path))
         {
             var item = new FilePath(filePath);
             if (filter.Accept(item))
             {
                 list.Add(item);
             }
         }
         return(list.ToArray());
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 4
0
		public FilePath[] ListFiles(FileFilter filter)
		{
			try
			{
				if (IsFile())
					return null;
				List<FilePath> list = new List<FilePath>();
				foreach (string filePath in Directory.GetFileSystemEntries(path))
				{
					var item = new FilePath(filePath);
					if (filter.Accept(item))
						list.Add(item);
				}
				return list.ToArray();
			}
			catch
			{
				return null;
			}
		}