C# - 计算并列出文件的硬链接位置

发布于 2024-10-08 22:36:49 字数 182 浏览 0 评论 0原文

我目前正在寻找一个 C# 解决方案,它可以读取文件的硬链接数量及其链接位置。我正在考虑程序链接 shell 扩展,它可以通过转到文件属性并列出一个文件的所有硬链接来完成此操作。我希望 C# 编码器有一个解决方案,可以在不搜索整个磁盘的情况下执行相同的操作。

编辑1:

有没有办法测试两个硬链接(如果它们是同一个文件)?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

┈┾☆殇 2024-10-15 22:36:49

要获取链接计数,请使用 GetFileInformationByHandle并访问 NumberOfLinks 成员。

以下是在 VB 中使用 API 的示例: http://blogs.msdn.com/b/vbteam/archive/2008/09/22/to-compare-two-filenames-lucian-wischik.aspx

查找名称在所有链接中,您需要使用 FindFirstFileNameW< /a> 但它仅在 Vista(或 Server 2k8)中可用,并且我找不到它的 P/Invoke 信息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文