unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
procedure copyfile(const FromFileName,ToFileName:string);
public
{ Public declarations }
end;
var
Form1: TForm1;
from,tofile:string;
implementation
{$R *.dfm}
procedure TForm1.copyfile(const FromFileName,ToFileName:string);
var
FromStream,ToStream:TFileStream;
begin
FromStream:=TFileStream.Create(FromFileName,fmOpenRead);
ToStream:=TFileStream.Create(ToFileName,fmOpenWrite or fmCreate);
ToStream.CopyFrom(FromStream,FromStream.size);
ToStream.Free;
FromStream.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if opendialog1.Execute then
from:=opendialog1.FileName;
label1.caption:=from;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if SaveDialog1.Execute then
begin
toFile:=Savedialog1.FileName+'.bmp';
copyfile(from,Tofile);
end;
end;
end.