Zip.Add ( 

string   ZipFile,

table    Files,

boolean  IncludeFolderNames = true,

string   Password = "",

number   CompFactor = 5,

function CallbackFunction = nil,

boolean  Recurse = false )

Example 1

FileTable = {_SourceFolder.."\\AutoPlay\\Docs\\Prices.txt", _SourceFolder.."\\AutoPlay\\Docs\\Catalog.txt"};
Zip.Add("C:\\CompanyInformation\\", FileTable, false, "", 5, nil, false);

The first line adds the file paths of "Prices.txt" and "Catalog.txt" to the table called "FileTable." The second line contains the Zip.Add action that adds the files from the "FileTable" table to the Zip file called ""

Example 2

Zip.Add("C:\\CompanyInformation\\", {_SourceFolder.."\\AutoPlay\\Docs\\*.*"}, true, "", 5, nil, true);

Adds all files in the "Docs" folder and all of it's subfolders to the Zip archive called "". Since the IncludeFolderNames parameter is set to true, the internal directory structure of the Zip archive will be relative to the "Docs" folder. The Recurse parameter is also set to true, so if the Docs folder contains any subfolders, their contents will also be added with their directory structure maintained relative to the "Docs" folder.

So if the Docs folder discussed in the above example contained:


the Zip archive would have the following structure:


Example 3

-- Prompt the user to select files to add to the zip archive.
archive_files = Dialog.FileBrowse(false, "Files to Add", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", true, false);

-- Check to see if an error occurred, or the user cancelled.
if (archive_files[1] ~= "CANCEL") and (archive_files ~= nil) then

    -- Show the status dialog.

    -- Add the chosen files to the zip archive.
    Zip.Add(_DesktopFolder.."\\", archive_files, true, "", 5, nil, false);

    -- Get the error code of the zip.add action.
    error = Application.GetLastError();

    -- Hide the status dialog.

    -- If it succeeded, display a success message and open the folder. Otherwise display the error message.
    if (error == 0) then
        Dialog.Message("Success", "The files were successfully archived.", MB_OK, MB_ICONINFORMATION);

        -- Open the folder where the zip file was created.
        File.ExploreFolder(_DesktopFolder, SW_SHOWNORMAL);
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);

 A file browse dialog is displayed allowing the user to select files they would like added to a Zip archive. The selected files are then added to a Zip archive created on their desktop. If the process is successful, a success message is displayed. If there was an error, the error code message is shown.

See also:  Related Actions