Guest User

Untitled

a guest
Jan 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. public static List<string> FindSupportedFiles(string root)
  2. {
  3. Queue<string> folders = new Queue<string>();
  4. List<string> files = new List<string>();
  5.  
  6. folders.Enqueue(root);
  7. while (folders.Count != 0)
  8. {
  9. string currentFolder = folders.Dequeue();
  10.  
  11. // this checks are not tested
  12. if (filepath.Contains(":/Windows/")) currentFolder = folders.Dequeue();
  13. if (filepath.Contains(":/Users/") &&
  14. filepath.Contains("/AppData/")) currentFolder = folders.Dequeue();
  15.  
  16. string[] filesInCurrent = null;
  17. try
  18. {
  19. filesInCurrent = Directory.GetFiles(currentFolder, "*.*");
  20. }
  21. // Ignore this exceptions
  22. catch (UnauthorizedAccessException) { }
  23. catch (PathTooLongException) { }
  24.  
  25. foreach (string f in filesInCurrent)
  26. if (SomeLib.IsSupported(f)) files.Add(f);
  27.  
  28. try
  29. {
  30. string[] foldersInCurrent = Directory.GetDirectories(currentFolder);
  31. }
  32. // Ignore this exceptions
  33. catch (UnauthorizedAccessException) { }
  34. catch (PathTooLongException) { }
  35. catch (DirectoryNotFoundException) { }
  36.  
  37. foreach (string _current in foldersInCurrent)
  38. folders.Enqueue(_current);
  39. }
  40. return files;
  41. }
Add Comment
Please, Sign In to add comment