0

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. :)

Nicros
  • 5,031
  • 12
  • 57
  • 101
  • 1
    Have a look at this question: http://stackoverflow.com/questions/4925468/combine-relative-baseuri-with-relative-path – Hamish Smith Feb 12 '13 at 18:47
  • 1
    Or this one http://stackoverflow.com/questions/3681052/get-absolute-url-from-relative-path-refactored-method which has a highly rated, accepted answer – Hamish Smith Feb 12 '13 at 18:49

1 Answers1

1
new Uri(new Uri("http://localhost/"), "virtualdirectory\\path\\to\\my\\file.html".Replace("\\","/"));
Darrel Miller
  • 139,164
  • 32
  • 194
  • 243