ZipArchive.Create

Syntax

Create(Path: String; Mode: ZipMode; [CompressionLevel: ZipCompressionLevel = -1]);

Parameters

Path. Path and name of ZIP archive on the hard drive.

Mode. Object creation mode to work with ZIP archive.

CompressionLevel. Archive compression degree.

Description

The Create constructor initializes a new object to work with ZIP archive.

Comments

Depending on the selected Mode mode, the Path parameter contains the path to the existing archive or name of the archive that was created before. If a new archive is created, the folder specified in the Path parameter must already be on the hard drive.

Example

Executing the example requires the D:\Work folder on the hard drive, this folder contains the Archives subdirectory to store archive files and the Other subdirectory to store subfiles. The D:\Work folder must also have the WDI.xls file with data. Add a link to the IO system assembly.

Sub UserProc;
Var
    ZIP: IZipArchive;
Begin
    ZIP := New ZipArchive.Create("D:\Work\Archives\Data.zip", ZipMode.Create);
    //Compression degree
    ZIP.CompressionLevel := ZipCompressionLevel.BestCompression;
    //Add files to archive
    ZIP.AddFile("D:\Work\WDI.xls""WDI.xls");
    ZIP.AddDirectory("D:\Work\Other");
    //Free variable with saving of archive
    Dispose ZIP;
End Sub UserProc;

After executing the example the Data.zip archive is created, the specified file and the Other subdirectory with all contents are added to this archive. The maximum compression degree is set for the archive.

See also:

ZipArchive