Let's say I have a file share at \\cloud\MyShare
that is mapped to J:\Mason
on my computer. If I have two filenames, \\cloud\MyShare\MyFolder\MyFile.dat
and J:\Mason\MyFolder\MyFile.dat
, is there any RTL or WinAPI routine for my code to establish that these two are in fact referring to the same file?
Asked
Active
Viewed 113 times
0

AmigoJack
- 5,234
- 1
- 15
- 31

Mason Wheeler
- 82,511
- 50
- 270
- 477
-
1Have you seen https://stackoverflow.com/questions/410705/best-way-to-determine-if-two-path-reference-to-same-file-in-c-sharp and https://stackoverflow.com/questions/4891064/how-can-i-determine-that-several-file-paths-formats-point-to-the-same-physical-l? – Andreas Rejbrand Apr 18 '22 at 16:55
-
You must at least **open** all files and then issue [`GetFileInformationByHandle()`](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfileinformationbyhandle) on them to then compare `BY_HANDLE_FILE_INFORMATION.dwVolumeSerialNumber`, `.nFileIndexHigh` and `.nFileIndexLow`. Do not open and close each file, as then values may differ. – AmigoJack Apr 19 '22 at 10:34
-
1One building block for shared drive to UNC is System.SysUtils.ExpandUNCFileName . Check out SO question https://stackoverflow.com/questions/43593987 as well for a caveat about user context. – Anthony Eischens Apr 19 '22 at 15:35
-
See Registry Computer\HKEY_CURRENT_USER\Network Value RemotePath – USauter Apr 21 '22 at 08:18