What is the best way to compare two paths in .Net to figure out if they point to the same file or directory?
How would one verify that these are the same:
c:\Some Dir\SOME FILE.XXX C:\\\SOME DIR\some file.xxx
Even better: is there a way to verify that these paths point to the same file on some network drive:
h:\Some File.xxx \\Some Host\Some Share\Some File.xxx
UPDATE:
Kent Boogaart has answered my first question correctly; but I`m still curious to see if there is a solution to my second question about comparing paths of files and directories on a network drive.
UPDATE 2 (combined answers for my two questions):
Question 1: local and/or network files and directories
c:\Some Dir\SOME FILE.XXX
C:\\\SOME DIR\some file.xxx
Answer: use System.IO.Path.GetFullPath
as exemplified with:
var path1 = Path.GetFullPath(@"c:\Some Dir\SOME FILE.XXX");
var path2 = Path.GetFullPath(@"C:\\\SOME DIR\subdir\..\some file.xxx");
// outputs true
Console.WriteLine("{0} == {1} ? {2}", path1, path2, string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase));
Question 2: local and/or network files and directories
Answer: Use the GetPath method as posted on http://briancaos.wordpress.com/2009/03/05/get-local-path-from-unc-path/