-1

Is there a easy way to compare UNC paths for equality? Such as \\server\share being equal to \\server.domain.com\share?

Matt
  • 774
  • 1
  • 10
  • 28
  • Besides checking if both translate into the same IP (ping for machine name, DNS resolution for domain name), no idea. – Cleptus Dec 31 '18 at 16:37

1 Answers1

0

Just by looking at the string there is absolutely no way to figure out if they are pointing to the same server.

The best way is to extract the host part and then query the DNS

Dns.GetHostAddresses("server");
Dns.GetHostAddresses("server.domain.com");

will give you two arrays of IPs for the server. if the two set matches perfectly then they are pointing to the same server.

If they don't then it *might imply that they sometimes point to the same and sometimes not (load balancing) or the server just simply have multiple IPs and the DNS is configured to return a different one for different host name.

IPv4 vs IPv6 might be another catch but I highly doubt that your IT department would shoot themselves in the foot like this.

Steve
  • 11,696
  • 7
  • 43
  • 81