我目前的问题是,如果我有一个类似" onenote的网址:https://somerandomhost.com/foo1/foo2"主持人我的Uri对象的权威总是""
我目前的解决方案是:
var uri = new Uri(hyperlinkURL);
if(uri.Scheme != "https" && uri.Scheme != "http")
{
uri = new Uri(uri.LocalPath);
}
有更好的方法吗?
答案 0 :(得分:0)
您的解决方案应该有效:
var link = "onenote:https://somerandomhost.com/foo1/foo2";
var uri = new Uri(link);
if(uri.Scheme != "https" && uri.Scheme != "http")
{
uri = new Uri(uri.LocalPath);
}
Console.WriteLine(uri.Host);
Console.WriteLine(uri.Authority);