System.IOUtils.TPath.GetDirectoryName
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