Skip to content

Instantly share code, notes, and snippets.

@Nate-Wilkins
Created June 24, 2014 12:15
Show Gist options
  • Save Nate-Wilkins/83d27f447dff42aa5c83 to your computer and use it in GitHub Desktop.
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
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