Show: Delphi C++
Display Preferences

System.IOUtils.TPath.GetDirectoryName

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

class function GetDirectoryName(FileName: string): string; static;

C++

static System::UnicodeString __fastcall GetDirectoryName(System::UnicodeString FileName);

Properties

Type Visibility Source Unit Parent
function public
System.IOUtils.pas
System.IOUtils.hpp
System.IOUtils TPath

Description

Extracts drive and directory parts of a file name.

GetDirectoryName extracts the drive and directory parts of the given file name. The resulting string is empty if FileName contains no drive or directory parts. The following table lists the parameters expected by this method.

Name Meaning

FileName

The file name from which the drive and directory are extracted.

Note: GetDirectoryName raises an exception if the given file name contains invalid characters.

Example (Delphi):

WriteLn(TPath.GetDirectoryName('D:\Projects\HelloWorld.exe'));

Example (C++):

printf("%s \n", TPath::GetDirectoryName("D:\Projects\HelloWorld.exe"));
Note: The code output: "D:\Projects". The path name does not include the last delimiter.
Note: On Linux, GetDirectoryName is identical to ExtractFileDir.

See Also

Code Examples


Personal tools
In Other Languages
Previous Versions
Assistance