Answers for "c# url relative path remove"

C#
0

c# url relative path remove

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 `/`
Posted by: Guest on September-08-2020

C# Answers by Framework

Browse Popular Code Answers by Language