Merge branch 'feature/get-relative-path' of Common/Utils into dev

This commit is contained in:
Chris Cameron 2018-05-09 14:08:30 +00:00 committed by Gogs
commit e446f6e6ce

View file

@ -68,5 +68,17 @@ namespace ICD.Common.Utils.IO
return Path.ChangeExtension(path, ext);
}
public static string GetRelativePath(string folder, string filespec)
{
Uri pathUri = new Uri(filespec);
// Folders must end in a slash
if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
folder += Path.DirectorySeparatorChar;
}
Uri folderUri = new Uri(folder);
return Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar));
}
}
}