如何在 C# 中检测 NTFS 挂载的文件夹?
曾几何时,我读到如何以编程方式检测已安装的 NTFS 文件夹(在搜索文件夹时可能会导致循环递归)。 现在我找不到链接..有谁知道该怎么做?
我有兴趣检测的安装是一个文件夹安装到另一个文件夹时的情况。
Once upon a time I read how you detect programmatically for mounted NTFS folders (can cause cyclic recursion when searching through folders). Now i cannot find the link.. Does anyone know how to do this?
The mounting I am interested in detecting is when one folder is mounted to another folder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您指的是 NTFS 连接? 有一个 非托管 API 来进行重新解析点,然后您必须询问才能看看它是否真的是一个路口。 当然,这一切都可以通过 P/Invoke 获得。
但是,大多数人只是(1)寻找 ReparsePoint 在返回的属性列表中DirectoryInfo.GetDirectories。
(1) 请注意,NTFS 连接点是一种特定类型的重分析点,但不是唯一的。 符号链接、
硬链接(2) 和任何其他用户定义的数据也是重分析点。(2)哎呀。 硬链接不是重新分析点,它们只是指向相同的文件。 感谢 Reuben 纠正我的错误。
I assume you mean a NTFS junction? There is an unmanaged API to get the reparse point, which you then have to interrogate to see if it's actually a junction. This is all available through P/Invoke, of course.
But, most folks just(1) look for ReparsePoint on the list of attributes returned by DirectoryInfo.GetDirectories.
(1) Note that a NTFS Junction is a particular type of reparse point, but not the only one. Symbolic links,
hard links,(2) and any other user defined data are also reparse points.(2) Whoops. Hard links aren't reparse points, they're just standard directory entries pointing to the same file. Thanks to Reuben for correcting me on that.
通过 WMI 执行此操作。 请参阅示例:http://msdn.microsoft.com /en-us/library/aa393244(VS.85).aspx
或者尝试使用 WMI 代码创建器:
Do this via WMI. See sample at : http://msdn.microsoft.com/en-us/library/aa393244(VS.85).aspx
Or try this sample code made with WMI Code Creator: