ObjectPascal
ExtractFilePath
Function
Extracts the path part of a full file name SysUtils unit
 function ExtractFilePath ( const FullFileName : string ) : string;
Description
The ExtractFilePath function extracts from FullFileName the path substring.
 
This is the part of the full file name up to and including the final \ before the file name.
Related commands
ChangeFileExt Change the extension part of a file name
ExtractFileDir Extracts the dir part of a full file name
ExtractFileDrive Extracts the drive part of a full file name
ExtractFileExt Extracts the extension part of a full file name
ExtractFileName Extracts the name part of a full file name
ProcessPath Split a drive/path/filename string into its constituent parts
 
Example code : Extract all of the parts of a full file name
var
  fullFileName : string;

begin
  // Set up a full file name with drive and path
  fullFileName := 'C:\Program Files\Borland\Delphi7\Projects\Unit1.dcu';

  // Show the component parts of this full name
  WriteLn('Drive = '+ExtractFileDrive (fullFileName));
  WriteLn('Dir   = '+ExtractFileDir   (fullFileName));
  WriteLn('Path  = '+ExtractFilePath  (fullFileName));
  WriteLn('Name  = '+ExtractFileName  (fullFileName));
  WriteLn('Ext   = '+ExtractFileExt   (fullFileName));
end;
Show full unit code
   Drive = C:
   Dir   = C:\Program Files\Borland\Delphi7\Projects
   Path  = C:\Program Files\Borland\Delphi7\Projects\
   Name  = Unit1.dcu
   Ext   = .dcu