Freigeben über


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

  • recursive
    Type: System.Boolean

    Flag to indicate if method should relativize to folder's parents.

Return Value

Type: System.String
Relative path.

.NET Framework Security

See Also

Reference

VersionControlPath Class

MakeRelative Overload

Microsoft.TeamFoundation.VersionControl.Common Namespace