Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 lines
647 B

using System;
using System.IO;
public static class PathHelper
{
public static string MakeRelativePath(string fromPath, string toPath)
{
var fromUri = new Uri(Path.GetFullPath(fromPath));
var toUri = new Uri(Path.GetFullPath(toPath));
if (fromUri.Scheme != toUri.Scheme)
{
return toPath;
}
var relativeUri = fromUri.MakeRelativeUri(toUri);
var relativePath = Uri.UnescapeDataString(relativeUri.ToString());
if (toUri.Scheme.Equals("file", StringComparison.InvariantCultureIgnoreCase))
{
relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
}
return relativePath;
}
}