procedure TForm1.Button1Click(Sender: TObject);
var
F1: TFileStream;
F2: TFileStream;
Buffer: array[0..1023] of byte; i : Integer;
begin
if not FileExists(ExtractFilePath( Application.ExeName ) + 'Binario1.dat') then
begin
MessageDlg('El Archivo a Procesar No Existe', mtInformation,[mbOk], 0);
exit;
end;
try
F1 := TFileStream.Create(ExtractFilePath( Application.ExeName ) + 'Binario1.dat', fmOpenRead);
F2 := TFileStream.Create(ExtractFilePath( Application.ExeName ) + 'Binario2.dat', fmCreate);
while F1.Position < F1.Size do
begin
FillChar(Buffer,SizeOf(Buffer),0);
F1.Read(Buffer,1024);
for i := 0 to 1023 do
begin
if (BuFfer[i] = Ord('A')) Then Buffer[i] := Ord('B');
end;
F2.Write(Buffer,1024);
end;
except
MessageDlg('Error de I/O en Archivo', mtInformation,[mbOk], 0);
end;
F1.Free;
F2.Free;
end;