File PathAbsolute To Relative Path Method
This helper method can be used to convert an absolute path to one that is relative to the given base
path.
Definition
Namespace: Sandcastle.Core
Assembly: Sandcastle.Core (in Sandcastle.Core.dll) Version: 2026.1.20.0
A path to the given absolute path that is relative to the given base path
Assembly: Sandcastle.Core (in Sandcastle.Core.dll) Version: 2026.1.20.0
C#
public static string AbsoluteToRelativePath(
string basePath,
string absolutePath
)VB
Public Shared Function AbsoluteToRelativePath (
basePath As String,
absolutePath As String
) As StringC++
public:
static String^ AbsoluteToRelativePath(
String^ basePath,
String^ absolutePath
)F#
static member AbsoluteToRelativePath :
basePath : string *
absolutePath : string -> string Parameters
Return Value
StringA path to the given absolute path that is relative to the given base path
Remarks
If the base path is null or empty, the current working folder is used.
Example
C#
string basePath = @"E:\DotNet\CS\TestProject\Source";
string absolutePath = @"E:\DotNet\CS\TestProject\Doc\Help.html";
string relativePath = FilePath.AbsoluteToRelativePath(basePath,
absolutePath);
Console.WriteLine(relativePath);
// Results in: ..\Doc\Help.htmlVB
Dim basePath As String = "E:\DotNet\CS\TestProject\Source"
Dim absolutePath As String = "E:\DotNet\CS\TestProject\Doc\Help.html"
Dim relativePath As String = _
FilePath.AbsoluteToRelativePath(basePath, absolutePath);
Console.WriteLine(relativePath)
' Results in: ..\Doc\Help.htmlC++
No code example is currently available or this language may not be supported.F#
No code example is currently available or this language may not be supported.