Path.Combine的网址? [英] Path.Combine for URLs?
本文介绍了Path.Combine的网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<一个href="https://msdn.microsoft.com/en-us/library/system.io.path.combine%28v=vs.110%29.aspx">Path.Combine是很方便,但有在.NET框架网址?
Path.Combine is handy, but is there a similar function in the .NET framework for URLs?
我在寻找这样的语法:
Url.Combine("http://MyUrl.com/", "/Images/Image.jpg")
这将返回:
http://MyUrl.com/Images/Image.jpg
推荐答案
开放的我们有一个构造函数应该为你做这一点:新的URI(URI基本URI,字符串relativeUri)
Uri has a constructor that should do this for you: new Uri(Uri baseUri, string relativeUri)
下面是一个例子:
Uri baseUri = new Uri("http://www.contoso.com");
Uri myUri = new Uri(baseUri, "catalog/shownew.htm");
这篇关于Path.Combine的网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文