I have ZipForge for Delphi XE2 & Delphi XE2.
I try to test any invalid zip archives (e.g. not fully downloaded) like in their demo:
procedure TfmMain.bnStartClick(Sender: TObject);
begin
with Archiver do
begin
FileName := 'c:\2.zip';
OpenArchive;
try
TestFiles('*.*');
except
MessageDlg('Errors occurred in the archive file', mtError, [mbOk], 0);
end;
CloseArchive;
end;
end;
But my exception doesn’t fire; ZipForge’s dialog fires instead of mine.
I tried Abbrevia Component but it even can’t recognize if an archive is invalid…
Please help me to make my exception working (not ZipForge’s one) or suggest me a better component for zip files with a test feature. Thanks!
Be aware that you can modify ZIP files, e.g. by truncating them somewhat, the ZIP file will still be valid. With my test file, I removed the final 5000 bytes and it was reported as valid. I extracted it successfully using my ZIP program. Of course the extracted contents were incorrect and not the original contents. Perhaps this is what was happening for you. Maybe your attempts to corrupt your ZIP file were not in fact making it into an invalid ZIP file.
Delphi XE2 comes with a built in ZIP component that worked well in my simple test and successfully detected an invalid file, once I had truncated the file enough to make it truly corrupt.
I used the
IsValidmethod to check validity. Here is my very simple test program.