문제

I'm currently searching for a C# solution which can read the number of hardlinks of a file and their links locations. I'm thinking of the program link shell extension which can do this by going to the file properties and lists all the hardlinks of one file. I expect there is a solution for C# coders which can do the same without searching through the complete disk.

Edit 1:

Is there a way to test two HardLinks if they are the same file?

도움이 되었습니까?

해결책

To get the link count, use GetFileInformationByHandle and access the NumberOfLinks member.

Here's an example of using the API in VB: http://blogs.msdn.com/b/vbteam/archive/2008/09/22/to-compare-two-filenames-lucian-wischik.aspx

To find the names of all the links, you need to use FindFirstFileNameW but it's only available as of Vista (or Server 2k8), and I can't find P/Invoke information for it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top