Creating Compressed (Zipped) Folder using Delphi

Dealinger picture Dealinger · Jul 4, 2009 · Viewed 26k times · Source

Can I create Windows XP's Compressed (Zipped) Folder using Delphi?

Answer

Fabio Gomes picture Fabio Gomes · Jan 20, 2012

If you are using Delphi X2, just use TZipFile from System.Zip:

To Zip a folder, use:

TZipFile.ZipDirectoryContents('ZipFile.zip', 'C:\Zip\this\right\now');

To Zip files, use:

Zip := TZipFile.Create;
try
  Zip.Open('ZipFile.zip', zmWrite);

  Zip.Add('FileToBeZipped.txt');
  Zip.Add('ThisWillBeCompressedAgainForSureAndBecomeSmaller.zip');
finally
  Zip.Free;
end