SHARE
TWEET

Untitled

a guest Oct 21st, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5.  
  6. namespace asdasd
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             var directory = Directory.GetDirectories(@"E:\Downloads\.vs\Library\v16");
  13.  
  14.             var files = FindFiles(@"E:\Downloads", "jpg", new List<string>());
  15.  
  16.             Console.WriteLine();
  17.         }
  18.  
  19.         static List<string> FindFiles(string path, string extension, List<string> list)
  20.         {
  21.             if (path.Length == 0) return list;
  22.  
  23.             foreach (var p in Directory.GetDirectories(path))
  24.             {
  25.                 var files = Directory.GetFiles(p);
  26.                 foreach (var file in files)
  27.                 {
  28.                     var name = file.Split("\\");
  29.                     var ext = name[name.Length - 1].Split('.');
  30.                     if (ext.Length != 2) continue;
  31.                     if (ext[1] == extension) list.Add(file);
  32.                 }
  33.                 FindFiles(p, extension, list);
  34.             }
  35.  
  36.  
  37.             return list;
  38.         }
  39.  
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top