VersionControlPath.MakeRelative Method (String, String, Boolean)
Given a path and folder, returns the path relative to the folder. If the path is not under the folder and the recursive parameter is false then path is returned unmodified.
Otherwise, the method iteratively each parent directory in the specified folder and tries to make item relative. Both path and folder are assumed to be in canonical form.
Examples: MakeRelative(@"$/src/project/abc.cpp", @"$/src",false) -> @"project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/specs",false) -> @"$/src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj",false) -> @"$/src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src", true) -> @"project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/specs", true) -> @"../src/project/abc.cpp" MakeRelative(@"$/src/project/abc.cpp", @"$/src/proj", true) -> @"../project/abc.cpp"
Namespace: Microsoft.TeamFoundation.VersionControl.Common
Assembly: Microsoft.TeamFoundation.VersionControl.Common (in Microsoft.TeamFoundation.VersionControl.Common.dll)
Syntax
'Declaration
Public Shared Function MakeRelative ( _
item As String, _
folder As String, _
recursive As Boolean _
) As String
public static string MakeRelative(
string item,
string folder,
bool recursive
)
public:
static String^ MakeRelative(
String^ item,
String^ folder,
bool recursive
)
static member MakeRelative :
item:string *
folder:string *
recursive:bool -> string
public static function MakeRelative(
item : String,
folder : String,
recursive : boolean
) : String
Parameters
item
Type: System.StringPath to make relative.
folder
Type: System.StringFolder to make it relative to.
recursive
Type: System.BooleanFlag to indicate if method should relativize to folder's parents.
Return Value
Type: System.String
Relative path.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.