Path.Combine for URLs?

Uri has a constructor that should do this for you: new Uri(Uri baseUri, string relativeUri)

Here’s an example:

Uri baseUri = new Uri("http://www.contoso.com");
Uri myUri = new Uri(baseUri, "catalog/shownew.htm");

Note from editor: Beware, this method does not work as expected. It can cut part of baseUri in some cases. See comments and other answers.

Leave a Comment