C uses System.Uri to convert URL to absolute address

  • 2020-12-21 18:08:59
  • OfStack

This article illustrates the method of C# using System.Uri to convert URL to absolute address. Share to everybody for everybody reference. The specific analysis is as follows:

When ASPOSE.Word is used to generate Word documents, InsertHtml(html) can be used to write the graphic information into Word documents (embedded images). However, src of the image in html is required to be an absolute full path, so html needs to be transformed.

html can be obtained from database data or via network fetching, and then replaced with ES19en.Uri.

Examples are as follows:


Uri uri = new Uri(http://www.baidu.com);
Uri uri2 = new Uri(uri,"abc/123.html");
Console.WriteLine(uri2.ToString()); 
// The output http://www.baidu.com/abc/123.html

Hopefully this article has helped you with your C# programming.


Related articles: