Saturday, May 7, 2011

Extract File Name

//Extract File Name
//By : Zephio
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, StdCtrls;

type
  TForm1 = class(TForm)
    E1: TEdit;
    E2: TEdit;
    E3: TEdit;
    E4: TEdit;
    B1: TSpeedButton;
    OD: TOpenDialog;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    E5: TEdit;
    Label5: TLabel;
    E6: TEdit;
    Label6: TLabel;
    E7: TEdit;
    Label7: TLabel;
    E8: TEdit;
    E9: TEdit;
    E10: TEdit;
    E11: TEdit;
    procedure B1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.B1Click(Sender: TObject);
begin
if OD.Execute then
begin
   E1.Text := OD.FileName;
   E2.Text := ExtractFileName(E1.Text);
   E3.Text := ExpandFileName(E2.Text);
//------------------------------------------------------------------------------>
   E4.Text := ExtractFileName(ExtractFileExt(E1.Text));
//or
   E11.Text := LowerCase(ExtractFileExt(OD.FileName));
//------------------------------------------------------------------------------>
   E5.Text := ChangeFileExt(ExtractFileName(OD.FileName),'');
   E6.Text := ExtractFileDrive(OD.FileName);
   E7.Text := ExtractFilePath(OD.FileName);
   E8.Text := ExtractFileDir(OD.FileName);
   E9.Text := ExtractFileDir(ExtractFileDir(OD.FileName));
   E10.Text := ExtractShortPathName(OD.FileName);
end;
end;
end.

No comments:

Post a Comment