1

My need is simple. Given a Windows directory path all I want is the actual path. I am sure the terminology is wrong, so I am giving an example.

Given C:\Documents and Settings\All Users the method should display:

  • C:\ProgramData on windows 7
  • C:\Documents and Settings\All Users on windows 2003

This is because on windows 7 C:\Documents and Settings is a junction referencing C:\Users and C:\Users\All Users is yet another junction referencing C:\ProgramData, which is the actual directory.

So, my question is what .NET API lets me do all this?

Thanks.

4

1 回答 1

1

从已经弄清楚的人那里查看此代码示例。

本质上,您必须通过 P/Invoke使用 Win32 函数DeviceIoControlFSCTL_GET_REPARSE_POINT作为dwIoControlCode参数传递。

正如 CodeProject 上的人所说...

我发现 .NET Framework 的 FileAttributes 枚举包含值 FileAttributes.ReparsePoint 很有趣,但没有其他对重解析点的内置支持。

没有“本机”.NET API 可以做到这一点,但请记住,大部分框架只是 P/Invoke 调用的包装,所以你不应该害怕它们 :)

于 2011-02-23T16:14:24.367 回答