Split a drive/path/filename string into its constituent parts FileCtrl unit
 procedure ProcessPath(const FullName string; var Drive Char; var Dir string; var FileName string);
The ProcessPath procedure splits a full file name FullName into its constituent Drive, Dir and FileName parts.
Related commands
ExtractFileDirExtracts the dir part of a full file name
ExtractFileDriveExtracts the drive part of a full file name
ExtractFileExtExtracts the extension part of a full file name
ExtractFileNameExtracts the name part of a full file name
 Download this web site as a Windows program.

Example code : Ask the user for a file name, and show the constituent parts
  selectedFile   : string;
  drive          : char;
  path, fileName : string;

  // Ask the user to select a file
  if PromptForFileName(selectedFile)
    // Display this full file/path value
    ShowMessage('Selected file = '+selectedFile);

    // Split this full file/path value into its constituent parts
    ProcessPath(selectedFile, drive, path, fileName);
    ShowMessage('drive = '+drive);
    ShowMessage('path = '+path);
    ShowMessage('fileName = '+fileName);
Show full unit code
  { The user selects C:\Files\data.txt and hits OK }
  Selected file = C:\Files\data.txt
  drive = C
  path = \Files
  filename = data.txt
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page