/// <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)); }