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

前端 未结 3 1758
鱼传尺愫
鱼传尺愫 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条回答
  •  旧时难觅i
    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.

提交回复
热议问题