Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

.net

path

unc

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?

like image 825
Iain Avatar asked Feb 17 '09 12:02

Iain


People also ask

How do I convert a mapped drive to UNC path?

In Windows, if you have mapped network drives and you don't know the UNC path for them, you can start a command prompt (Start → Run → cmd.exe) and use the net use command to list your mapped drives and their UNC paths: C:\>net use New connections will be remembered.


1 Answers

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

like image 54
On Freund Avatar answered Sep 19 '22 09:09

On Freund