Heinzi
Heinzi

Reputation: 172468

Convert UNC path to 'file:///' URL in ASP.NET

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?

Upvotes: 13

Views: 16581

Answers (1)

Jon Benedicto
Jon Benedicto

Reputation: 10582

Yes, use the Uri class in the System namespace:

Uri uri = new Uri(@"\\fileserver\share\dir\some file.ext");
string url = uri.AbsoluteUri;

Upvotes: 13

Related Questions