0

I need to check whether two relative file paths are equal or not.

String path1 = "a/b/c/file.txt";
String path2 = "/A/B/../B/C/file.txt";

Actually those two paths point to the same file. But how can I check this?

PS: Doing this for absolute paths works fine, with the approach described here.

Community
  • 1
  • 1
My-Name-Is
  • 4,814
  • 10
  • 44
  • 84

1 Answers1

3

You can use Path.GetFullPath (MSDN) to compare the absolute paths of your files.

germi
  • 4,628
  • 1
  • 21
  • 38
  • This works only if I first remvove the leading slash before. Hence, `"a/b/c/file.txt" != "/A/B/../B/C/file.txt"` – My-Name-Is Nov 11 '13 at 13:28