# SysUtils.ExtractRelativePath

## Delphi Information

From SysUtils.pas

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

Unit: SysUtils

Type: function

Visibility: public

## C++ Information

From SysUtils.hpp

	System::UnicodeString __fastcall ExtractRelativePath(System::UnicodeString BaseName, System::UnicodeString DestName);

Unit: SysUtils

Type: function

## 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\'

.

ExtractRelativePath('c:\foo\', 'c:\bar')
returns an incorrect result, such as

'..'
.