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?
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.
You can use P/Invoke and call on a native function such as WNetGetUniversalName.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With