views:

218

answers:

2

I need to convert UNC paths to file:/// URLs, e.g.

\\fileserver\share\dir\some file.ext --> file://///fileserver/share/dir/some%20file.ext

Is there some built-in function for this?

+5  A: 

Yes, use the Uri class in the System namespace:

Uri uri = new Uri(@"\\fileserver\share\dir\some file.ext");
string url = uri.AbsoluteUri;
Jon Benedicto
Works great, thanks.
Heinzi
A: 

I didn't find built-in function. I found this similar stackoverflow post.

Ikaso