Вот собственно весь код, но снизу прикрепил архив с проектом.
https://yadi.sk/d/URtiXPHwkJn5r
Код: Выделить всё
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Gauges;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Gauge1: TGauge;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
filetoopen , filetowriteto : string;
file1 , file2 : tfilestream;
buff , readbuff : char;
dummy1 , dumm2 : integer;
begin
opendialog1.Filter := 'All files|*.*';
if radiobutton1.Checked = true then
gauge1.Progress :=0
else
gauge1.Progress :=Gauge1.MaxValue;
if opendialog1.Execute then
begin
filetoopen := opendialog1.FileName;
savedialog1.Filter :='All Files|*.*';
if savedialog1.Execute then
begin
filetowriteto := savedialog1.FileName;
file1 :=tfilestream.Create(filetoopen,fmopenread);
file2 := tfilestream.Create(filetowriteto,fmopenwrite or fmcreate or fmsharedenywrite);
gauge1.MaxValue :=file1.Size;
for dummy1 := 0 to file1.Size -1 do
begin
file1.Read(buff,sizeof(buff));
if radiobutton1.Checked = true then
readbuff := char(pchar(buff)+ $20)
else
readbuff :=char(pchar(buff) - $20);
file2.Write(readbuff,sizeof(readbuff));
if radiobutton1.Checked = true then
gauge1.Progress :=gauge1.Progress + 1
else
gauge1.Progress := gauge1.Progress -1;
end;
end;
file1.Free;
file2.Free;
end;
end;
end.