Creating Compressed (Zipped) Folder using Delphi

前端 未结 9 2211
日久生厌
日久生厌 2021-02-05 18:52

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

9条回答
  •  情话喂你
    2021-02-05 19:05

    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
    

提交回复
热议问题