Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create relative path between two paths [duplicate]

Tags:

c#

.net

Possible Duplicate:
How to get relative path from absolute path

I'm currently using the FolderBrowserDialog to return an absolute path. I would like to instead get the relative path with respect to the currently executing directory. Given that FolderBrowserDialog only returns an absolute path, is there a way to translate this to a relative path?

like image 513
amccormack Avatar asked Apr 19 '11 14:04

amccormack


1 Answers

You want to use Uri.MakeRelativeUri(uri). Get your current executing assembly, store it as a Uri. Create a second Uri from the directory from your Folder browser, and use MakeRelativeUri(). I asked a similar question touching on this, that goes in to details of properly decoding the Uri so that the path is a valid form for a Windows folder.

Removing %20 from URI Relative Path

like image 179
Stealth Rabbi Avatar answered Sep 28 '22 06:09

Stealth Rabbi