public static string ExtractPath(string uri, params string[] additional) { var index = uri.IndexOf(MakeFileUri.Scheme); if (-1 == index) { return(MakeFileUri.Combine(uri, additional)); } int skipLength = MakeFileUri.Scheme.Length; int addedLength = MakeFileUri.GetLength(additional); var sb = new StringBuilder(uri.Length + addedLength - skipLength); if (skipLength < uri.Length && '/' == uri[skipLength]) { int winIndex = uri.IndexOf(MakeFileUri.WindowsScheme, skipLength + 1); if (-1 != winIndex && winIndex < 10) { skipLength += 1; } } sb.Append(uri, skipLength, uri.Length - skipLength); return(MakeFileUri.Combine(sb, additional)); }
static string Combine(string origin, string[] additional) { if (string.IsNullOrEmpty(origin)) { return(origin); } if (null == additional) { return(origin); } return(MakeFileUri.Combine(new StringBuilder(origin, origin.Length + MakeFileUri.GetLength(additional)), additional)); }