I know I can do
Directory.GetFiles(@"c:\", "*.html")
and I'll get a list of files that match the *.html file pattern.
I'd like to do the inverse. Given file name abc.html, I'd like a method that will tell me if that filename matches the *.html pattern. for instance
class.method("abc.html", "*.html") // returns true
class.method("abc.xml", "*.html") // returns false
class.method("abc.doc", "*.?oc") // returns true
class.method("Jan24.txt", "Jan*.txt") // returns true
class.method("Dec24.txt", "Jan*.txt") // returns false
The functionality must exist in dotnet. I just don't know where it's exposed.
Converting the pattern to regex could be one way to go. However it just seems like there are a lot of edge cases and may be more trouble than it's worth.
Note: the filename in questions may not exist yet, so I can't just wrap a Directory.GetFiles call and check to see if the result set has any entries.