如何将带有驱动器号的路径转换为 ​​UNC 路径

发布于 2024-07-13 08:51:58 字数 181 浏览 5 评论 0原文

如何将带有驱动器号(如 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 技术交流群。

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

发布评论

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

评论(3

想挽留 2024-07-20 08:51:58

您可以使用 P/Invoke 并调用本机函数,例如 WNetGetUniversalName

You can use P/Invoke and call on a native function such as WNetGetUniversalName.

醉南桥 2024-07-20 08:51:58

要在 .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.

玩心态 2024-07-20 08:51:58

要回答您有关net use的问题,这里是一个很好的解决方案
获取映射驱动器 VB.net 的 UNC 路径

我喜欢net use方式。

To answer your question about net use here is a good solution
Get UNC Path for Mapped Drive VB.net

I like the net use way.

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