I need to convert UNC paths to file:///
URLs. For example:
\\fileserver\share\dir\some file.ext --> file://///fileserver/share/dir/some%20file.ext
Is there a built-in function for this?
Solution 1. There is no way to convert it, unless you are going to buy a hosting and domain using your desired domain name.
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.
In your thread reference someone writes 'A file path is not a URL or URI unless you put the file:// prefix on it.
Yes, use the Uri class in the System namespace:
Uri uri = new Uri(@"\\fileserver\share\dir\some file.ext");
string url = uri.AbsoluteUri;
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