3

Is there a simple way (like some low level Windows API) to know whether two absolute path of file names point to the same physical file on Windows in C# or C or cmd? Existing question seems to be about Unix and doesn't consider details bellow.

They may be:

(1) Real file

(2) Symbolic link

(3) Whose path contains some folder that is directory symbolic links (like created by mklink /d)

C# is best. If C then will Pinvoke it. If cmd then will Process.Start it.

Jose
  • 3,306
  • 1
  • 17
  • 22
jw_
  • 1,663
  • 18
  • 32
  • Pick up a language, it does not make sense that a tagged question with C# accepts an answer in C as valid. There are ways (C#) to check if a file is a symbolic link: https://stackoverflow.com/questions/1485155/check-if-a-file-is-real-or-a-symbolic-link – Jose Feb 25 '20 at 11:00
  • Does this do the trick? https://stackoverflow.com/questions/2067075/how-do-i-determine-a-mapped-drives-actual-path – Matthew Watson Feb 25 '20 at 11:01
  • You might want to compare file ID (like inode on Linux): (https://stackoverflow.com/questions/7162164/does-windows-have-inode-numbers-like-linux) – Alex Sveshnikov Feb 25 '20 at 11:21
  • Found that this question works https://stackoverflow.com/questions/38299901/get-real-path-from-symlink-c-sharp – jw_ Feb 25 '20 at 12:33
  • @Alex Found that File ID works for directory symbolic links in the path, but doesn't work for file symbolic links, the file ids are different than the original file. – jw_ Feb 25 '20 at 12:34

0 Answers0