Path.GetDirectoryName(@"C:\\");
returns null and
Path.GetDirectoryName(@"C:\\Foo");
returns C:\
While this is exactly the behaviour mentioned in the documentation I'm wondering why
Path.GetDirectoryName(@"\\server.domain.tld\Foo");
returns null and not as I'd have expected \server.domain.tld\
Does anyone have clue why?
Typically, the UNC path structure is \\{server}\{share}\{path.....}
, so "Foo"
in your UNC example is equivalent to the "C:\"
of your first example. This is why you get null
for the path of your UNC example.
The path of "\\server\foo\bar"
would be "bar"
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