How to determine if two file system URIs point to the same resource?

If I have two different file paths, how can I determine if they point to the same file?

This may be the case if, for example, the user is connected to a network drive that points to a network resource. For example, drive S: is mapped to \ servercrm \ SomeFolder.

Then these paths actually point to the same file:

S:\somefile.dat

and

\\servercrm\SomeFolder\somefile.dat

How can I detect this? I need to encode it so that it works in all scenarios, where there can be different ways to specify the path to the same file.

+3
source share
3 answers

, #, GetFileInformationByHandle ( pinwoke < ), BY_HANDLE_FILE_INFORMATION, , :

dwVolumeSerialNumber:      , .

...

nFileIndexHigh:      , .

nFileIndexLo:      , .

( ) . , , .

, , .


:

, , dwVolumeSerialNumber , . , , , . , (, , ) .

+3

, MD5 , , CreationTime, LastAccessTime LastWriteTime.

+1

If only local files bother you, you can use a combination of GetFileInformationByHandle and structure BY_HANDLE_FILE_INFORMATION. Lucian made an excellent blog entry on this subject. The code is in VB.Net, but it needs to be easily converted to C #

0
source

Source: https://habr.com/ru/post/1708168/


All Articles