如何将带有驱动器号的路径转换为 UNC 路径
如何将带有驱动器号(如 W:\Path\Share
)的路径转换为等效的 unc 路径(如 .Net 中的 \\server\Share\File
)?
在命令提示符处,您可以运行 net use
,这将列出映射。 我如何在 .Net 中获取该信息?
How do I convert a path with a drive letter like W:\Path\Share
to the equivalent unc path like \\server\Share\File
in .Net?
At the command prompt you can run net use
and that will list the mappings. How do I get at that info in .Net?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 P/Invoke 并调用本机函数,例如 WNetGetUniversalName。
You can use P/Invoke and call on a native function such as WNetGetUniversalName.
要在 .NET 中获取当前计算机上的共享文件夹列表,您必须选择:
请注意,调用进程将在具有管理权限的用户上下文中运行,这样才能正常工作。
To get a list of the shared folders on the current machine in .NET you have to options:
Note that the calling process will have run in the context of a user with administrative privileges for this to work.
要回答您有关
net use
的问题,这里是一个很好的解决方案获取映射驱动器 VB.net 的 UNC 路径
我喜欢
net use
方式。To answer your question about
net use
here is a good solutionGet UNC Path for Mapped Drive VB.net
I like the
net use
way.