|
You may want to parse a file into it's constituent parts, which consist out if it's drive-letter, directory path and the filename.
You can accomplish this easily by using the ProcessPath function.
Declaration
-----------
procedure ProcessPath (const EditText: string; var Drive: Char; var DirPart: string; var FilePart: string);
Description
-----------
Call ProcessPath to parse a file name into its drive, path, and file
name. Pass the full file name that should be parsed as the EditText
parameter. ProcessPath returns the indicated drive, directory, and
file name as the Drive, DirPart, and FilePart parameters.
Example
-------
uses
FileCtrl;
var
DirPart, FilePart: string;
Drive: Char;
begin
if (OpenDialog.Execute) then
begin
ProcessPath(OpenDialog.Filename, Drive, DirPart,
FilePart);
Label1.Caption := 'Full Path: ' + OpenDialog.Filename;
Label2.Caption := 'Drive Part: ' + Drive;
Label3.Caption := 'Directory Part: '
+ DirPart;
Label4.Caption := 'Filename Part: ' + FilePart;
end;
end;
In this example a open-dialog box allows you to select any file, parse it into it's constituent parts and display the results into the different labels.
NOTE: Remember to add the FileCtrl unit to your application's uses-clause.