07-10-2011، 09:39 AM
Example code : Extract all of the parts of a full file name
بدست اوردن نام فایل مسیر فایل و پسوند فایل در دلفی با تابع ExtractFileDir
موفق باشید :-)
بدست اوردن نام فایل مسیر فایل و پسوند فایل در دلفی با تابع ExtractFileDir
کد:
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
unit Unit1;
interface
uses
SysUtils, // Unit containing the ExtractFileDir command
Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm} // Include form definitions
procedure TForm1.FormCreate(Sender: TObject);
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
ShowMessage('Drive = '+ExtractFileDrive (fullFileName));
ShowMessage('Dir = '+ExtractFileDir (fullFileName));
ShowMessage('Path = '+ExtractFilePath (fullFileName));
ShowMessage('Name = '+ExtractFileName (fullFileName));
ShowMessage('Ext = '+ExtractFileExt (fullFileName));
end;
end.