ArchiverPlusZip
ArchiverPlusZip
Events:
- ZipProgression (Operation As Int, FileName As String, PercentDone As Int)
- ZipResult (Result As Int, ErrorMsg As String)
Fields:
- ZIP_AES_STRENGTH_128 As Int
- ZIP_AES_STRENGTH_192 As Int
- ZIP_AES_STRENGTH_256 As Int
- ZIP_COMP_AES_ENC As Int
- ZIP_COMP_DEFLATE As Int
- ZIP_COMP_STORE As Int
- ZIP_ENC_METHOD_AES As Int
- ZIP_ENC_METHOD_STANDARD As Int
- ZIP_ENC_NO_ENCRYPTION As Int
- ZIP_EXECMODE_MAIN_THREAD As Byte
- ZIP_EXECMODE_NO_EVENT As Byte
- ZIP_EXECMODE_ONLY_RESULT As Byte
- ZIP_EXECMODE_PROGRESSION_AND_RESULT As Byte
- ZIP_OPERATION_ADD As Int
- ZIP_OPERATION_CALC_CRC As Int
- ZIP_OPERATION_EXTRACT As Int
- ZIP_OPERATION_MERGE As Int
- ZIP_OPERATION_REMOVE As Int
- ZIP_RESULT_CANCELLED As Int
- ZIP_RESULT_ERROR As Int
- ZIP_RESULT_SUCCESS As Int
- ZIP_RESULT_WORKING As Int
- ZIP_UNKNOWN_ERROR As String
Methods:
- AddFileToZip (FilePath As String, ArchivePath As String, EventPrefix As String)
Adds a file to the specified zip archive. If the zip archive does not exist, it is created.
FilePath: path of the file to add.
ArchivePath: location of the zip archive.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- AddFilesToZip (FileNames As List, ArchivePath As String, EventPrefix As String)
Adds a list of files to the specified zip archive. If the zip archive does not exist, it is created.
FileNames: list of the files to add.
ArchivePath: location of the zip archive.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- AddFolderToZip (FolderPath As String, ArchivePath As String, EventPrefix As String)
Adds a folder and its subfolders to the specified zip archive. If the zip archive does not exist, it is created.
FolderPath: path of the folder to add.
ArchivePath: location of the zip archive.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- AddStreamToZip (Stream As InputStream, FileName As String, ArchivePath As String)
Creates a new entry in the specified zip archive with the content of the given InputStream.
Stream: the input stream.
FileName: a file name for the new entry.
ArchivePath: location of the zip archive.
- CancelAllZipTasks
Tries to cancel all zip/unzip tasks in progress.
- CountZipEntries (ArchivePath As String) As Int
Returns the number of entries in the specified zip archive.
- CreateSplitZip (FolderToZip As String, ArchivePath As String, SplitLength As Int, EventPrefix As String)
Compresses the given folder and its subfolders into a split zip archive.
A split zip archive is made of multiple parts that are limited to a specified size. It cannot be modified with Add or Remove functions.
An exception is thrown if the zip archive already exists.
FolderToZip: path of the folder to zip.
ArchivePath: location of the zip archive.
SplitLength: maximum length in bytes of each part. Has to be more than 65536 bytes.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- DecryptZipWith (Password As String)
- EncryptZipWith (EncryptionMethod As Int, AESKeyStrength As Int, Password As String)
Sets the encryption properties and forces ZipEncryption to True.
EncryptionMethod: One of the ZIP_ENC_ constants.
AESKeyStrength: Either ZIP_AES_STRENGTH_128 or ZIP_AES_STRENGTH_256. ZIP_AES_STRENGTH_192 cannot be used for encryption. This parameter is ignored if the encryption method is not AES.
Password: The password to be used for encryption. Cannot be empty.
- GetZipComment (ArchivePath As String) As String
- GetZipEntry (ArchivePath As String, FileName As String) As ZipInfo
Returns an ArchiverZipInfo object containing the properties of the specified file.
ArchivePath: location of the zip archive.
FileName: the file whose properties are requested.
- IsEncryptedZipFile (ArchivePath As String) As Boolean
- IsSplitZipArchive (ArchivePath As String) As Boolean
- IsValidZipFile (ArchivePath As String) As Boolean
- ListSplitZipFiles (ArchivePath As String) As List
Returns a list of all parts of the specified split zip archive.
- ListZipEntries (ArchivePath As String) As List
Returns a list containing the properties of all files of the specified zip archive. Each item of this list is an ArchiverZipInfo object.
Example:
Dim lstEntries As List = Arc.ListZipEntries(ArchiveFolder & "MyArchive.zip")
For i = 0 To lstEntries.Size - 1
Dim ZipInfo As ArchiverZipInfo = lstEntries.Get(i)
Log(ZipInfo.FileName & ": Compressed=" & ZipInfo.CompressedSize & " / Uncompressed=" & ZipInfo.UncompressedSize & " / CRC32= " & ZipInfo.CRC32)
Log(" Last modification=" & DateTime.Date(ZipInfo.LastModFileTime) & " " & DateTime.Time(ZipInfo.LastModFileTime))
Next
- MergeSplitZip (SplitZip As String, NewArchive As String, EventPrefix As String)
Merges the specified split zip archive into a single zip file without the need to extract the files.
SplitZip: location of the split zip archive
NewArchive: location of the combined archive
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- RemoveFileFromZip (ArchivePath As String, FilePath As String, EventPrefix As String)
Removes a file from the specified zip archive. Throws an exception if the file was not found.
ArchivePath: location of the zip archive.
FilePath: path of the file to remove. This path is relative.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- RemoveFilesFromZip (ArchivePath As String, FileNames As List, EventPrefix As String)
Removes a list of files from the specified zip archive. Throws an exception if the file was not found.
ArchivePath: location of the zip archive.
FileNames: list of the files to remove. Paths to the files are relative.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- SetZipComment (ArchivePath As String, Comment As String)
- UnZip (ArchivePath As String, DestPath As String, EventPrefix As String)
Extracts all the files from the given zip archive to the destination path.
ArchivePath: location of the archive to unzip.
DestPath: location where to unzip the files.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- UnZipFile (ArchivePath As String, FileName As String, DestPath As String, EventPrefix As String)
Extracts a specific file from the given zip archive to the destination path.
ArchivePath: location of the archive to unzip.
FileName: the file to unzip. The path to the file is relative.
DestPath: location where to unzip the file.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- UnZipFile2 (ArchivePath As String, FileName As String, DestPath As String, NewName As String, EventPrefix As String)
Extracts a specific file from the given zip archive and changes its name.
ArchivePath: location of the archive to unzip.
FileName: the file to unzip. The path to the file is relative.
DestPath: location where to unzip the file.
NewName: new name of the extracted file.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- UnZipFiles (ArchivePath As String, FileNames As List, DestPath As String, EventPrefix As String)
Extracts a list of files from the given zip archive to the destination path.
ArchivePath: location of the archive to unzip.
FileNames: list of the files to unzip. Paths to the files are relative.
DestPath: location where to unzip the files.
EventPrefix: prefix of the "ZipProgression" and "ZipResult" events.
- UnZipToStream (ArchivePath As String, FileName As String, Stream As OutputStream)
Writes the contents of the specified file of a zip archive to an output stream.
ArchivePath: location of the zip archive.
FileName: the file to unzip. The path to the file is relative.
Stream: the output stream. This stream is closed after the last byte is written.
Properties:
- RootFolderInZip As String
Gets or sets the root folder in the zip archive.
- ZipAESKeyStrength As Int [read only]
- ZipCompression As Boolean
Gets or sets whether the files are compressed (true) or stored (false).
- ZipCompressionLevel As Int
Gets or sets the compression level.
From 1: lowest compression level but higher speed of compression.
To 9: highest compression level but low speed.
Setting a compression level forces ZipCompression to True.
- ZipEncryption As Boolean
Gets or sets whether the encryption is enabled.
- ZipEncryptionMethod As Int [read only]
Returns the encryption method (one of the ZIP_ENC_ constants) set with EncryptZipWith.
- ZipExecutionMode As Byte
Gets or sets the execution mode of zip/unzip (one of the ZIP_EXECMODE_ constants).
PROGRESSION_AND_RESULT: tasks are run in a separate thread and the ZipProgression and ZipResult events are raised if the EventPrefix parameter is set. Default mode.
ONLY_RESULT: tasks are run in a separate thread and only the ZipResult event is raised if the EventPrefix parameter is set.
NO_EVENT: tasks are run in a separate thread and no event is raised. Any call to a function raising events returns immediately. Test ZipResult to know if the task has ended.
MAIN_THREAD: tasks are run in the main UI thread and no event is raised.
- ZipResult As Int [read only]
Returns a result code (one of the ZIP_RESULT_ constants) when ZipExecutionMode is set to ZIP_EXECMODE_NO_EVENT.
Returns ZIP_RESULT_WORKING when the task is still in progress.
ArchiverZipInfo
Methods:
- IsFileNameUTF8Encoded As Boolean
Properties:
- CRC32 As Long [read only]
- CompressedSize As Long [read only]
Returns the compressed size in bytes.
- CompressionMethod As Int [read only]
Returns the compression method (one of the ZIP_COMP_ constants).
- EncryptionMethod As Int [read only]
Returns the encryption method (one of the ZIP_ENC_ constants).
- FileName As String [read only]
- LastModFileTime As Long [read only]
Returns the timestamp of the file.
- UncompressedSize As Long [read only]
Returns the uncompressed size in bytes.
Authors: Frédéric Leneuf-Magaud, Srikanth Reddy Lingala