Created
June 24, 2014 12:15
-
-
Save Nate-Wilkins/83d27f447dff42aa5c83 to your computer and use it in GitHub Desktop.
Obtains all the file paths from the provided paths - if a directory is a path then expand it and obtain it's files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<string> ExpandPaths(IEnumerable<string> paths) | |
{ | |
var expandedPaths = new List<string>(); | |
foreach (var p in paths) | |
{ | |
if (Directory.Exists(p)) | |
{ | |
expandedPaths.AddRange(Directory.GetFiles(p)); | |
expandedPaths.AddRange(ExpandPaths(Directory.GetDirectories(p))); | |
} | |
else if (File.Exists(p)) expandedPaths.Add(p); | |
} | |
return expandedPaths; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment