IPWorks ZIP 2020 Node.js Edition

Questions / Feedback?

Compress Method

Creates the compressed archive.

Syntax

jar.compress([callback])

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for this method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

Remarks

Invoking Compress creates the archive specified by ArchiveFile. When the method is called, all files specified by the FileDecompressedName field of the Files collection will be compressed and written to ArchiveFile.

The compressed data may be streamed out by setting WriteToProgressEvent to true. If streaming is enabled the compressed data will also be provided via the Progress event. If ArchiveFile is set to an empty string the archive will be written only to this event.

The files to compress are specified in the Files collection. The file names are specified by FileCompressedName and FileDecompressedName. These should be specified before invoking Compress, either manually or by invoking IncludeFiles.

The BeginFile and EndFile events will be fired as files are processed, and the Progress event will be fired as data is compressed.

Existing files will be overwritten by the class if OverwriteFiles is set to true. Finer control over which files are overwritten may be gained by trapping the Overwrite event.

Example (Creating an Archive)


ZipControl.ArchiveFile = "c:\test.zip"
ZipControl.RecurseSubdirectories = true
ZipControl.IncludeFiles("c:\foo\*")
ZipControl.Compress()

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks ZIP 2020 Node.js Edition - Version 20.0 [Build 8300]