Ver Mensaje Individual
  #6  
Antiguo 02-04-2007
Avatar de n3mohack
n3mohack n3mohack is offline
Miembro
 
Registrado: may 2004
Ubicación: Chile-Stgo-Huechuraba
Posts: 41
Reputación: 0
n3mohack Va por buen camino
Gracias Milenario,
Estaba probando otras funciones pero tu ejemplo me sirvió perfectamente.

Cita:
Empezado por seoane
Un poco de codigo


Código Delphi [-]
function CompareFiles(strUno, strDos: String): boolean;
var
Uno, Dos: TFileStream;
BufUno, BufDos: Pointer;
BytesRead: Integer;
begin
Result:= FALSE;
Uno:= TFileStream.Create(strUno,fmOpenRead or fmShareDenyWrite);
try
Dos:= TFileStream.Create(strDos,fmOpenRead or fmShareDenyWrite);
try
if Uno.Size = Dos.Size then
begin
GetMem(BufUno,10*1024);
try
GetMem(BufDos,10*1024);
try
while TRUE do
begin
BytesRead:= Uno.Read(BufUno^, 10*1024);
if (BytesRead <> Dos.Read(BufDos^, 10*1024)) then
break;
if BytesRead = 0 then
begin
Result:= TRUE;
break;
end;
if not CompareMem(BufUno,BufDos,BytesRead) then
break;
end;
finally
FreeMem(BufDos);
end;
finally
FreeMem(BufUno);
end;
end;
finally
Dos.Free;
end;
finally
Uno.Free;
end;
end;


// Por ejemplo
ShowMessage(BoolToStr(CompareFiles('c:\1.zip','c:\2.zip'),TRUE));





Y si te decides por el hash, muy útil si los dos archivos están en equipos distintos, aquí puedes encontrar una unit para calcularlo.
http://www.clubdelphi.com/foros/show...22&postcount=4
__________________
Si es Chileno.. es bueno.
Responder Con Cita