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

Iain picture Iain · Feb 17, 2009 · Viewed 10.3k times · Source

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?

Answer

On Freund picture On Freund · Feb 17, 2009

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