System.SysUtils.ExtractRelativePath

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function ExtractRelativePath(const BaseName, DestName: string): string;

C++

extern DELPHI_PACKAGE System::UnicodeString __fastcall ExtractRelativePath(const System::UnicodeString BaseName, const System::UnicodeString DestName)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

Returns a relative path name, relative to a specific base directory.

Call ExtractRelativePath to convert a fully qualified path name into a relative path name. The DestName parameter specifies the file name (including path) to be converted. BaseName is the fully qualified name of the base directory to which the returned path name should be relative. BaseName may or may not include a file name, but it must include the final path delimiter.

Note: If you send the function what should be a directory without the trailing backslash (c:\foo instead of c:\foo\), the function treats foo as a file and returns undesirable results. You should correctly call it, as in the following example:

ExtractRelativePath('c:\foo\', 'c:\bar\')

The returned result is:

'..\bar\'

And the following call:

ExtractRelativePath('c:\foo\', 'c:\bar')

returns an incorrect result, such as:

'..'

See Also