FilePath.RelativeToAbsolutePath Method
Definition
- Namespace
- Sandcastle.Core
- Assembly
- Sandcastle.Core.dll
This helper method can be used to convert a relative path to an absolute path based on the given base path.
public static string RelativeToAbsolutePath(string basePath, string relativePath)
Parameters
Returns
- string
An absolute path
Examples
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.html
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.html
Remarks
If the base path is null or empty, the current working folder is used.