How do I convert a path with a drive letter to a UNC path

前端 未结 3 1743
鱼传尺愫
鱼传尺愫 2021-02-19 21:30

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 comman

相关标签:
3条回答
  • 2021-02-19 22:20

    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.

    0 讨论(0)
  • 2021-02-19 22:29

    To get a list of the shared folders on the current machine in .NET you have to options:

    • Querying the Win32_share WMI class using the classes in the System.Management namespace
    • Invoking the NetShareEnum function in Win32 using P/Invoke

    Note that the calling process will have run in the context of a user with administrative privileges for this to work.

    0 讨论(0)
  • 2021-02-19 22:32

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

    0 讨论(0)
提交回复
热议问题