mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-14 04:58:33 +00:00
feat: add IcdPath.GetRelativePath(string, string)
This commit is contained in:
parent
9abf384bb4
commit
7e48547483
1 changed files with 12 additions and 0 deletions
|
|
@ -68,5 +68,17 @@ namespace ICD.Common.Utils.IO
|
||||||
|
|
||||||
return Path.ChangeExtension(path, ext);
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue