Assume you have a directory that contains the following directories:
dontgetme
get.me
If you use the following code:
string[] directories = Directory.GetDirectories(rootDirectory, "*.*", SearchOption.TopDirectoryOnly);
You would expect directories to contain:
get.me
But it contains both directories, why is this?
Looking into the documentation the only wildcards are * and ? so they shouldn't be affecting this.
Further if you use the pattern *. only the dontgetme directory is returned; but using *.*.*.* etc. both are still returned.
In case it matters I am using .NET 4.6.1 and C# 6 on Windows 10.
You pattern means "anything with any extension". No extension is "any extension", so you match all four.
You could try ?*.?* as pattern so you get those that have at least one character as both extension and name.
Windows file and directory names always have an extension, even if it's blank. So *.* matches anything because it's treated as anything.
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