📜  c# url 相对路径删除 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:57.331000             🧑  作者: Mango

代码示例1
var uri = new Uri(myString);

var noLastSegment = string.Format("{0}://{1}", uri.Scheme, uri.Authority);

for(int i = 0; i < uri.Segments.Length - 1; i++)
{
   noLastSegment += uri.Segments[i];
}

noLastSegment = noLastSegment.Trim("/".ToCharArray()); // remove trailing `/`