How to recursively list all the files in a directory and child directories in C#?
private void GetFiles(DirectoryInfo dir, ref List files) { try { files.AddRange(dir.GetFiles()); DirectoryInfo[] dirs = dir.GetDirectories(); foreach (var d in dirs) { GetFiles(d, ref files); } } catch (Exception e) { } }