code/Kingdom.OrTools.Sat.CodeGeneration.Core/Extensions/FileAndDirectoryExtensionMethods.cs
/// <summary>
/// Gets the Relative Path from <paramref name="basePath"/> and
/// <paramref name="otherPath"/>.
/// </summary>
/// <param name="basePath"></param>
/// <param name="otherPath"></param>
/// <returns></returns>
Gets the Relative Path from  and
.
Gets the Relative Path from and .
public static string GetRelativePath(this string basePath, string otherPath)
        {
            basePath = GetFullPath(basePath);
            otherPath = GetFullPath(otherPath);
            const string backSlash = "\\";
            if (!basePath.EndsWith(backSlash))
            {
                basePath += backSlash;
            }
            const string forwardSlash = "/";
            var baseUri = new Uri(basePath);
            var otherUri = new Uri(otherPath);
            var relativeUri = baseUri.MakeRelativeUri(otherUri);
            return $"{relativeUri}".Replace(forwardSlash, backSlash);
        }
public static string GetRelativePath ( this string basePath , string otherPath ) { basePath = GetFullPath ( basePath ) ; otherPath = GetFullPath ( otherPath ) ; const string backSlash = " \\ " ; if ( ! basePath . EndsWith ( backSlash ) ) { basePath += backSlash ; } const string forwardSlash = " " ; var baseUri = new Uri ( basePath ) ; var otherUri = new Uri ( otherPath ) ; var relativeUri = baseUri . MakeRelativeUri ( otherUri ) ; return $" { relativeUri } " . Replace ( forwardSlash , backSlash ) ; }
Gets the Relative Path from  and
.
Gets the Relative Path from and .
// Requires trailing backward slash for path. // Uri use forward slashes so convert back to backward slashes.
None
string
this
otherPath
string
None
basePath
None