.NET 连接目录和 DirectInfo 问题
我正在尝试访问 C:\Users\Public\Documents\ 下的信息,该信息在资源管理器上显示为 C:\Users\Public\Public Documents\ 。有没有办法能够使用 .NET C# 中的资源管理器中显示的路径名来访问联结下目录的 DirectoryInfo?
I am trying to access information under C:\Users\Public\Documents\ which displays as C:\Users\Public\Public Documents\ on explorer. Is there a way to be able to access the DirectoryInfo of a directory under the junction using the pathname displayed in explorer in .NET C#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您期望何时/如何获得
C:\users\public\publicdocuments
路径?如果用户从资源管理器进行复制/粘贴,
C:\users\public\documents
路径将被复制到剪贴板中。通过SaveFileDialog
也会生成有效路径。如果您需要访问 Windows 7 库的方法,可以尝试 Windows API 代码包 。例如,您可以通过
KnownFolders.PublicDocuments
访问“公共文档”。据我所知(我以前从未使用过它),仍然无法可靠地将C:\ users\public\publicdocuments
到DirectoryInfo
中,但您可能会更好地挖掘文档。When/how are you expecting to get a
C:\users\public\public documents
path?If a user goes to copy/paste from Explorer, the
C:\users\public\documents
path will be copied into the clipboard. Going through aSaveFileDialog
also produces the valid path.If you need a way to access Windows 7 libraries, you can give the Windows API Code Pack a go. You can then access "Public Documents as
KnownFolders.PublicDocuments
, for example. From what I can see (I've never used it before), there's still no way to reliably turnC:\users\public\public documents
into aDirectoryInfo
, but you might have better luck digging through the docs.