Example #1
0
        public static Uri ToFolderUri(this string instance)
        {
            if (!instance.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                return(UriUtility.CreateSourceUri(instance + Path.DirectorySeparatorChar.ToString()));
            }

            return(UriUtility.CreateSourceUri(instance));
        }
Example #2
0
        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));
        }
Example #3
0
 public static Uri ToFileUri(this string instance)
 {
     return(UriUtility.CreateSourceUri(instance));
 }