using System.Collections.Generic;
using Microsoft.Extensions.FileSystemGlobbing;
public static void Main()
var testList = new HashSet<string> { "1objd\\Amd64\\testrobocopy\\robocopy1.dll", "testrobocopy\\robocopy2.exe", "testrobocopy\\robocopy3.txt", "testrobocopy\\robocopy4.obj" };
testList.Add("C:\\src\\CloudBuild\\private\\BuildEngine\\TestResults\\Deploy_mingl 2020-10-05 18_46_02\\root5ac309f032e94f9dbe63d2f6cb135df1\\Enlistment\\robocopy\\robocopy3.dll");
string[] wildList = new string[] { "**.*" };
List<string> toRemove = null;
var patterns = new Matcher();
foreach (string fileExcludeCondition in wildList)
string pattern = fileExcludeCondition.ToCharArray().Aggregate(string.Empty, (result, c) => result += ((c == '*') ? "*" : string.Empty) + c.ToString());
patterns.AddInclude(fileExcludeCondition);
Console.WriteLine(pattern);
foreach (string file in testList)
string filteredFile = file.Replace(":", string.Empty);
if (patterns.Match(filteredFile).HasMatches)
Console.WriteLine(filteredFile);
toRemove = toRemove ?? new List<string>();
if (toRemove != null && toRemove.Count > 0)
toRemove.ForEach(r => testList.Remove(r));
Console.WriteLine(testList.Count());