public static Uri ToFolderUri(this string instance) { if (!instance.EndsWith(Path.DirectorySeparatorChar.ToString())) { return(UriUtility.CreateSourceUri(instance + Path.DirectorySeparatorChar.ToString())); } return(UriUtility.CreateSourceUri(instance)); }
public static string MakeRelativePath(string from, string to, IFileSystem fileSystem) { if (string.IsNullOrEmpty(from)) { throw new ArgumentNullException("from"); } if (string.IsNullOrEmpty(to)) { throw new ArgumentNullException("to"); } string fromString = AddTrailingSlashToDirectoriesForUriMethods(from, fileSystem); string toString = AddTrailingSlashToDirectoriesForUriMethods(to, fileSystem); var fromUri = UriUtility.CreateSourceUri(fromString); var toUri = UriUtility.CreateSourceUri(toString); Uri relativeUri = fromUri.MakeRelativeUri(toUri); string relativePath = Uri.UnescapeDataString(relativeUri.ToString()); return(relativePath.Replace('/', fileSystem.Path.DirectorySeparatorChar)); }
public static Uri ToFileUri(this string instance) { return(UriUtility.CreateSourceUri(instance)); }