How to use the Microsoft.Extensions.FileSystemGlobbing.Matcher
class. I read the documentation, but I still don't understand it.
I expect to be able to exclude the specified folder(use glob), but the code does not work:
var matcher = new Matcher();
matcher.AddExclude("foo/*.txt");
matcher.Match(new[] { "foo/a.txt", "foo/b.md", "bar/a.txt" }); // HasMatches: false
Expected:
foo/b.md
bar/a.txt
Actual:
// nothing
You have to specify what to include:
var matcher = new Matcher();
matcher.AddInclude("**"); // <-- this line is added
matcher.AddExclude("foo/*.txt");
matcher.Match(new[] { "foo/a.txt", "foo/b.md", "bar/a.txt" });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With