/// <summary> /// 获取上级目录 /// </summary> /// <param name="url">完整Url</param> /// <returns></returns> public string GetParentDirectory(string url) { return GetParentDirectory(new Uri(url)); } /// <summary> /// 获取上级目录 /// </summary> /// <param name="uri">uri</param> /// <returns></returns> public string GetParentDirectory(Uri uri) { return uri.Scheme + "://" + uri.Host + string.Join("", new List<string>(uri.Segments).GetRange(0, uri.Segments.Length - 1)); }
原文地址:https://www.cnblogs.com/ChenRihe/p/10325919.html
时间: 2024-11-15 23:07:47