Path.Combine for URLs?

前端 未结 30 2578
不思量自难忘°
不思量自难忘° 2020-11-22 14:28

Path.Combine is handy, but is there a similar function in the .NET framework for URLs?

I\'m looking for syntax like this:

Url.Combine(\"http://MyUrl.         


        
30条回答
  •  甜味超标
    2020-11-22 15:26

    I found UriBuilder worked really well for this sort of thing:

    UriBuilder urlb = new UriBuilder("http", _serverAddress, _webPort, _filePath);
    Uri url = urlb.Uri;
    return url.AbsoluteUri;
    

    See UriBuilder Class - MSDN for more constructors and documentation.

提交回复
热议问题