dazinator / DotNet.Glob

A fast globbing library for .NET / .NETStandard applications. Outperforms Regex.
MIT License
363 stars 27 forks source link

How to enumerate files and folders with glob? #74

Closed jjxtra closed 4 years ago

jjxtra commented 4 years ago

Do you have example code on how to enumerate files and folders using a glob? I would prefer to only enumerate files that match a glob, but only within the most specific sub folder, that way I am not enumerating everything on say the C: drive.

Something like this would be ideal, as long as it was smart enough to pull out the base directory c:/dir1/dir2/dir3 and only enumerate *.txt files within:

foreach (var file in Glob.EnumerateFiles("c:/dir1/dir2/dir3/**/subdir/*.txt"))
{
}
jjxtra commented 4 years ago

I ended up just finding first index of /* and using everything before that as the base path.