File PathRelative To Absolute Path Method
This helper method can be used to convert a relative path to an absolute path based on the given base
path.
Definition
Namespace: Sandcastle.Core
Assembly: Sandcastle.Core (in Sandcastle.Core.dll) Version: 2026.1.20.0
An absolute path
Assembly: Sandcastle.Core (in Sandcastle.Core.dll) Version: 2026.1.20.0
C#
public static string RelativeToAbsolutePath(
string basePath,
string relativePath
)VB
Public Shared Function RelativeToAbsolutePath (
basePath As String,
relativePath As String
) As StringC++
public:
static String^ RelativeToAbsolutePath(
String^ basePath,
String^ relativePath
)F#
static member RelativeToAbsolutePath :
basePath : string *
relativePath : string -> string Parameters
Return Value
StringAn absolute 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 relativePath = @"..\Doc\Help.html";
string absolutePath = FilePath.RelativeToAbsolutePath(basePath,
relativePath);
Console.WriteLine(absolutePath);
// Results in: E:\DotNet\CS\TestProject\Doc\Help.htmlVB
Dim basePath As String = "E:\DotNet\CS\TestProject\Source"
Dim relativePath As String = "..\Doc\Help.html"
Dim absolutePath As String = _
FilePath.RelativeToAbsolutePath(basePath, relativePath);
Console.WriteLine(absolutePath)
' Results in: E:\DotNet\CS\TestProject\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.