Zip.Extract

Zip.Extract (

string ZipFile,

table Files,

string Destination,

boolean Recurse = true,

boolean UseInternalFolders = true,

string Password = "",

number Overwrite = 0,

function CallbackFunction = nil )

Description

Extracts files from a Zip archive.

Parameters

ZipFile

(string) The full path and file name of the Zip archive file.

Files

(table) A table containing the list of files to extract. Use {"*.*"} to extract all files from the Zip archive.

Note: You can also use the * and ? wildcards in the table to extract multiple files.

Destination

(string) The folder path to extract the files to.

Recurse

(boolean) Whether to recurse into subfolders as it searches for files to extract:

VALUE

DESCRIPTION

true

Recurse into subfolders when extracting files. (Default)

false

Don't recurse into subfolders.

Note: This is primarily useful when wildcards are used in the files you want to extract.

UseInternalFolders

(boolean) Whether to recreate the internal file structure of the Zip file when extracting files:

VALUE

DESCRIPTION

true

The internal file structure will be recreated. (Default)

false

The internal file structure will be ignored and all files will be extracted to the root of the destination folder.

Password

(string) The password required to extract files from the Zip file. (This parameter is optional and only needed if you password protected the Zip file. If no password is required, just leave this parameter blank. )

Overwrite

(number) Whether to overwrite any already existing files in the destination folder when extracting. Choose from:

CONSTANT

VALUE

DESCRIPTION

ZIP_OVERWRITE_NEVER

0

Do not overwrite any files. (Default)

ZIP_OVERWRITE_NEWER

1

Only overwrite a file if the one being extracted is newer.

ZIP_OVERWRITE_ALWAYS

2

Overwrite all existing files with the ones being extracted.

CallbackFunction

(function) The name of a function that will be called whenever progress is made when extracting each file from the Zip archive. (You can use this callback function to display the progress of each file's extraction in your own custom way.)

Note: If CallbackFunction is set to nil, then the progress information will be sent to the built-in status dialog, assuming it is currently visible. (You can show or hide the status dialog with a StatusDlg.Show or StatusDlg.Hide action.)

The callback function must be able to receive the following parameters:

String

(string) The full destination path and file name currently being extracted from the Zip archive.

Percent

(number) The progress percentage, corresponding to either the current file or the total action.

Status

(number) The status of the current callback message. Either ZIP_STATUS_MAJOR (value of 0) or ZIP_STATUS_MINOR (value of 1). ZIP_STATUS_MAJOR means that the callback corresponds to the progress of the action as a whole. ZIP_STATUS_MINOR means that the callback corresponds to the progress of the current file.

The callback function should return a boolean value (true or false) indicating whether the extraction of the Zip file should continue:

VALUE

DESCRIPTION

true

Continue with the Zip file extraction.

false

Stop the Zip file extraction as soon as possible.

Returns

Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

See also: Related Actions