Nicros
Nicros

Reputation: 5183

Joining Url and relative file path into valid Uri?

I have kind of a funky question- given the uri http://localhost, and a relative file path of virtualdirectory\\path\\to\\my\\file.html, how can I merge these into a valid Url which should be http://localhost/virtualdirectory/path/to/my/file.html?

I'm using Web.API and a client search to see if a static html file exists in a virtual directory on the server. The client requests the search with jQuery, the Web.API controller does the searching on the local virtual directory. If the file does exist, the controller needs to return a valid Url to the client so the client can view that static html file.

If that makes sense. :)

Upvotes: 0

Views: 516

Answers (1)

Darrel Miller
Darrel Miller

Reputation: 142174

new Uri(new Uri("http://localhost/"), "virtualdirectory\\path\\to\\my\\file.html".Replace("\\","/"));

Upvotes: 1

Related Questions