RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.ExtractRelativePath Function

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

Pascal
function ExtractRelativePath(const BaseName: string; const DestName: string): string;
C++
AnsiString ExtractRelativePath(const AnsiString BaseName, const AnsiString DestName);

SysUtils

Call ExtractRelativePath to convert a fully qualified path name into a relative path name. The DestName parameter specifies 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 it 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 like this:

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

so that it would return

'..\bar\'

.

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

would return the incorrect result, probably like

'..'

.  

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!