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