Is there a way in C# (4.0) to check if two file names reference to the same file, preferably without opening them?
I.e. d:\x.txt should be equal to x.txt or ../x.txt if the the relative path points to d.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you use
Path.GetFullPathon both names they should resolve to the same string:Then
fullPath1should equalfullPath2if they reference the same file. Make sure that you do a case insensitive comparison as Windows filenames are case insensitive.