Ver Mensaje Individual
  #3  
Antiguo 02-11-2005
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.964
Reputación: 29
delphi.com.ar Va camino a la fama
Es algo básico, pero tiene que funcionar (Probalo, lo escribí e hice dos pruebas sencillas nada mas):
Código Delphi [-]
function CompareStreams(AStream1, AStream2: TStream): boolean;
var
  Buff1, Buff2: Pointer;
  iCount: LongInt;
const
  BUFFER_SIZE = 1024*4;
begin
  if AStream1.Size <> AStream2.Size then
    Result := False
  else
  begin
    Result := True;
    GetMem(Buff1, BUFFER_SIZE);
    GetMem(Buff2, BUFFER_SIZE);
    try
      repeat
        iCount := AStream1.Read(Buff1^, BUFFER_SIZE);
        AStream2.Read(Buff2^, BUFFER_SIZE);
        if not CompareMem(Buff1, Buff2, iCount) then
        begin
          Result := False;
          break;
        end;
      until iCount < BUFFER_SIZE;
    finally
      FreeMem(Buff1);
      FreeMem(Buff2);
    end;
  end;
end;

function CompareFiles(AFileName1, AFileName2: TFileName): boolean;
var
  FS1, FS2: TFileStream;
begin
  FS1 := TFileStream.Create(AFileName1, fmOpenRead + fmShareDenyNone);
  try
    FS2 := TFileStream.Create(AFileName2, fmOpenRead + fmShareDenyNone);
    try
      Result := CompareStreams(FS1, FS2);
    finally
      FS2.Free;
    end;
  finally
    FS1.Free;
  end;
end;

Código Delphi [-]
  if CompareFiles('C:\FILE1.TXT', 'C:\FILE2.TXT') then
    Caption := 'Los archivos son iguales'
  else
    Caption := 'Los archivos son diferentes';

Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita