C# 如何使用FileSystemGlobbing.Matcher

C# 如何使用FileSystemGlobbing.Matcher,c#,.net,C#,.net,如何使用Microsoft.Extensions.FileSystemGlobbing.Matcher类。我读了这本书,但还是不明白 我希望能够排除指定的文件夹(使用glob),但代码不起作用: var matcher=new matcher(); matcher.AddExclude(“foo/*.txt”); matcher.Match(新[]{“foo/a.txt”、“foo/b.md”、“bar/a.txt”});//HasMatches:错误 预期: foo/b.md bar/a.t

如何使用
Microsoft.Extensions.FileSystemGlobbing.Matcher
类。我读了这本书,但还是不明白

我希望能够排除指定的文件夹(使用glob),但代码不起作用:

var matcher=new matcher();
matcher.AddExclude(“foo/*.txt”);
matcher.Match(新[]{“foo/a.txt”、“foo/b.md”、“bar/a.txt”});//HasMatches:错误
预期:

foo/b.md
bar/a.txt
实际:

// nothing

您必须指定要包括的内容:

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" });
var matcher=new matcher();

匹配器。添加项(“**”)// 您必须指定要包括的内容:

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" });
var matcher=new matcher();

匹配器。添加项(“**”)//对于那些试图使用
FileSystemGlobbing
并与我有相同问题的人:显然,匹配器不支持所有绝对路径或驱动器号。对于那些试图使用
FileSystemGlobbing
并与我有相同问题的人:显然,匹配器不支持所有绝对路径或驱动器号。