Hallo,
hiermit kann man prüfen ob zwei Dateien gleich sind.
Delphi-Quellcode:
function CompareFiles(const sFileName1, sFileName2: String): Boolean;
var
ms1, ms2: TMemoryStream;
begin
Result := False;
ms1 := TMemoryStream.Create;
try
ms1.LoadFromFile(sFileName1);
ms2 := TMemoryStream.Create;
try
ms2.LoadFromFile(sFileName2);
If ms1.size = ms2.size Then
Result := CompareMem(ms1.Memory, ms2.memory, ms1.size);
finally
FreeAndNil(ms2);
end;
finally
FreeAndNil(ms1);
end
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Opendialog1.Execute then
begin
if Opendialog2.Execute then
begin
if CompareFiles(Opendialog1.FileName, Opendialog2.FileName) then
ShowMessage('Die Dateien sind gleich...')
else
ShowMessage('Die Dateien sind ungleich...');
end;
end;
end;
Grüsse, Daniel