Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. static string MakeRelativePath(string absolutePath, string pivotFolder)
  2. {
  3. //string folder = Path.IsPathRooted(pivotFolder)
  4. // ? pivotFolder : Path.GetFullPath(pivotFolder);
  5. string folder = pivotFolder;
  6. Uri pathUri = new Uri(absolutePath);
  7. // Folders must end in a slash
  8. if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
  9. {
  10. folder += Path.DirectorySeparatorChar;
  11. }
  12. Uri folderUri = new Uri(folder);
  13. Uri relativeUri = folderUri.MakeRelativeUri(pathUri);
  14. return Uri.UnescapeDataString(
  15. relativeUri.ToString().Replace('/', Path.DirectorySeparatorChar));
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement