Wednesday, April 27, 2011

Create & Remove Directory

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    E1: TEdit;
    LNF: TLabel;
    BC: TSpeedButton;
    BR: TSpeedButton;
    procedure BCClick(Sender: TObject);
    procedure BRClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { By : Zephio}
  public
    { http://amateur-guide.blogspot.com }
  end;

var
  Form1: TForm1;



implementation

{$R *.dfm}

procedure TForm1.BCClick(Sender: TObject);
begin
   E1.Tag := E1.Tag + 1;
   IntToStr(0 + E1.Tag);
if not DirectoryExists(ExtractFilePath(Application.ExeName)+E1.Text) then
   CreateDir(ExtractFilePath(Application.ExeName)+E1.Text)
else
   CreateDir(E1.Text+' ('+IntToStr(E1.Tag)+')');
end;

procedure TForm1.BRClick(Sender: TObject);
begin
if not DirectoryExists(ExtractFilePath(Application.ExeName)+E1.Text) then
   ShowMessage(E1.Text+' Not Found!...')
else
   RemoveDir(ExtractFilePath(Application.ExeName)+E1.Text);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   BC.Caption := 'Create Folder';
   BR.Caption := 'Remove Folder';
   E1.Text := 'New Folder';
end;

end.

No comments:

Post a Comment