Xceed Zip Compression Library Documentation
Convert method
Xceed Zip control reference > Xceed Zip control methods > Convert method

Description

This very flexible method allows any type of zip file (regular, spanned , multi-part , self-extracting or spanned self-extracting) to be converted into any other type of zip file. It can also merge zip files together, update zip files from other zip files, filter out certain types of files from a zip file, change self-extracting zip file configurations and repair corrupted zip files.

One or more of the functions explained below can be simultaneously performed by calling the Convert method. The functions performed when calling the Convert method depend on a variety of factors, explained for each function. For all functions, a source zip file must be specified by setting the ZipFilename property and a destination zip file must be specified via the Convert method's sDestFilename parameter. Whenever a function causes a file to be transferred from the source zip file to the destination zip file, the ConvertPreprocessingFile event will be triggered before the transfer in order to provide information on the file and to allow you to modify some of the parameters. 

Function How to preform
Repair  The repair function is always implicitly performed when running the Convert method. Any data transferred (wether it is converted, merged or updated) to the destination zip file will be error-free. If the source zip file is too corrupted, an error will be returned and the Convert method will fail. To repair a zip file without also converting, merging, or updating it, ensure that the conditions for performing the other functions are not met.
Conversion  The conversion function is performed whenever the type of the source zip file differs from the type of the destination zip file. The type of the source zip file is automatically determined by the library. The type of the destination zip file is specified by setting the values of the SpanMultipleDisks and SplitSize properties (for converting to spanned or multi-part zip files) and the SfxBinaryModule and Sfx* properties (for converting to self-extracting zip files).
Filter  The filtering function is performed whenever the default values of any of the following properties are changed: RequiredFileAttributes, ExcludedFileAttributes, MinDateToProcess, MaxDateToProcess, MinSizeToProcess and MaxSizeToProcess. Any files from a zip file being converted, merged or updated that don't fit the criteria specified by the aforementioned properties will be filtered out from the destination zip file, unless they already existed in the destination zip file.

Merge / Update 
 

 

The merge / update functions are performed whenever the destination zip file already exists and is a regular or self-extracting zip file. The source zip file can be any type. When the merge / update function is performed, each file in the source zip file that already exists in the destination zip file will be replaced (unless the SkipIfExisting property is set to True or the SkipIfOlderDate property is True and the file is older than the one in the destination zip file, and only if the UseTempFile property is set to True). Also, each file in the source zip file that does not already exist will be added to the destination zip file (unless the SkipIfNotExisting property is set to True). Files that were already in the destination zip file but that were not in the source zip file will be left there.

 

Declaration (ActiveX)  
Method Convert(sDestFilename As String) As xcdError

Declaration (DLL API)  
int XzConvert( HXCEEDZIP hZip, const TCHAR* pszDestFilename )

Parameters

Parameter Description
sDestFilename  The path and filename of the destination zip file. (Specify a ".EXE"file extension if the file is to be a self-extracting Zip file. Of course, this is only the case if you have specified a binary in the SfxBinaryModule property)

Remarks

The ExtraHeadersTextEncodingUnicodeUsagePolicy and PreservePaths properties also affect the contents of the destination zip file. The FilesToProcess and FilesToExclude properties never affect the execution of the Convert method.

Return values

A return value of type xcdError is returned. Only the return value of xerSuccess indicates that the method has been completed successfully. See the error codes topic for a list of possible return values.

Applicable properties

Abort, ZipFilename, CompressionLevel,   EncryptionMethod, EncryptionPassword, EncryptionStrength, ExtraHeaders, TextEncodingUnicodeUsagePolicy, SpanMultipleDisks and SplitSize, FirstDiskFreeSpace, MinDiskFreeSpace, SfxBinaryModule and the Sfx* properties, RequiredFileAttributes, ExcludedFileAttributes, MinDateToProcess, MaxDateToProcess, MinSizeToProcess, MaxSizeToProcess, UseTempFile, PreservePaths

Events triggered

ConvertPreprocessingFile, ProcessCompleted , FileStatus, GlobalStatus, SkippingFile

Related topics

If you want to create self-extracting zip file without requiring an already existing zip file, use the Zip method in conjunction with the SfxBinaryModule property.