I'm trying to find if at least one file within a directory matches patterns (that use only "?" and "*" wildcards), but some combinations keep throwing the nested qualifier error. For example - TestCashFile_10_12-25-2016????????.c??
doesn't work.
The patterns come from the non-technical users (who're educated in the basic usage of these two wildcards) so the "?" and "*" can go pretty much anywhere in the filename and I don't have much control.
What is wrong with these patterns?
This is the C# code snippet that runs this regex -
string fileName = C:\TestFiles\TestCashFile_10_12-25-2016????????.c??'
string directory = Path.GetDirectoryName(fileName);
string[] temp = fileName.Split('\\');
string file = temp[temp.Length - 1];
var found = Directory.GetFiles(directory).Any(p => Regex.Match(p, file).Success);
Update - The question has been resolved but in case it helps someone else looking for something similar, just to clarify - In this case, I wanted "?" to mean that there must be exactly one element (as opposed to zero or one element).