Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void FindAllImages(string root)
- {
- Queue<string> folders = new Queue<string>();
- List<string> files = new List<string>();
- folders.Enqueue(root);
- while (folders.Count != 0)
- {
- string currentFolder = folders.Dequeue();
- // this checks are not tested
- if (filepath.Contains(":/Windows/")) currentFolder = folders.Dequeue();
- if (filepath.Contains(":/Users/") &&
- filepath.Contains(":/AppData/")) currentFolder = folders.Dequeue();
- string[] filesInCurrent = null;
- try
- {
- filesInCurrent = Directory.GetFiles(currentFolder, "*.*");
- }
- // Ignore this exceptions
- catch (UnauthorizedAccessException) { }
- catch (PathTooLongException) { }
- foreach (string f in filesInCurrent)
- if (MyLib.IsSupported(f)) files.Add(f);
- try
- {
- string[] foldersInCurrent = Directory.GetDirectories(currentFolder);
- foreach (string _current in foldersInCurrent)
- folders.Enqueue(_current);
- }
- // Ignore this exceptions
- catch (UnauthorizedAccessException) { }
- catch (PathTooLongException) { }
- catch (DirectoryNotFoundException) { }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement