The Jar control may be used to create or decompress Java archives.
The operation of the control is similar to that of Zip. .class and other files may be added into a .jar file, and then may be imported into Java code or executed by a JVM.
To create a new archive, first set the ArchiveFile property to the name of the archive to be created. Then, specify the files to be compressed either by invoking IncludeFiles, or by adding a new object to the Files collection and setting the values of the FileDecompressedName and FileCompressedName. fields. Finally, call the Compress method to create the archive.
To decompress an existing archive, set ArchiveFile to the name of the archive to be decompressed. The ExtractToPath property may be set, and then calling the ExtractAll method will decompress all files in the archive to this path.
For finer control, the Scan method should be used to read the file information stored in the archive. This will fill out the information in the Files collection. The values of FileDecompressedName may then be changed if desired. Finally, ExtractAll may be used to decompress the entire archive, or Extract may be used for finer control.
All Java archives contain two special entries, a META-INF directory and a manifest. By default, the control will automatically generate a default manifest and add the special entries to the beginning of the archive. To instead add a custom manifest to the archive the ManifestFile property should be set.
During decompression, the archive is treated as an ordinary zip file.
Example (Creating a Jar File)
ZipControl.ArchiveFile = "c:\test.jar" ZipControl.RecurseSubdirectories = false ZipControl.IncludeFiles("c:\code\*.class") ZipControl.ManifestFile = "c:\code\manifest.mf" ZipControl.Compress()Example (Extracting from a Jar File)
ZipControl.ArchiveFile = "c:\test.jar" ZipControl.ExtractToPath = "c:\extracted\" ZipControl.Extract("*.class")
The following is the full list of the properties of the control with short descriptions. Click on the links for further details.
|ArchiveFile||The name of the zip, gzip, tar, or jar archive.|
|CompressionLevel||The compression level to use.|
|ExcludedFiles||A list of files to exclude.|
|ExtractToPath||A base path to decompress to.|
|FileCount||The number of records in the File arrays.|
|FileCompressedDate||The date and time of the entry, as stored within the archive.|
|FileCompressedName||The file name of the current file, as stored inside of the archive.|
|FileCompressedSize||The size of the compressed data, as compressed within the archive.|
|FileDecompressedName||The name of the file in the archive, as stored on the file system, outside the archive.|
|FileDecompressedSize||The size of the file, as decompressed outside the archive.|
|FileInputData||When This property is set, the control will read in the data from This property instead of reading from the file contained in the DecompressedName property.|
|JarData||(Decompression only) The jar file contents as a byte array.|
|ManifestFile||The name of the manifest file.|
|OverwriteFiles||Whether or not to overwrite files.|
|RecurseSubdirectories||Whether or not to recurse into subdirectories.|
The following is the full list of the methods of the control with short descriptions. Click on the links for further details.
|Abort||Aborts the current operation.|
|AppendFiles||Adds specified files to an existing archive.|
|Compress||Creates the compressed archive.|
|Config||Sets or retrieves a configuration setting.|
|Delete||Deletes one or more files from an existing archive.|
|Extract||Extracts a single file, directory, or group of files, from the archive.|
|ExtractAll||Extracts all files from the compressed archive.|
|IncludeFiles||Specifies that the indicated files should be added to the archive.|
|Reset||Resets the control.|
|Scan||Scans the compressed archive.|
The following is the full list of the events fired by the control with short descriptions. Click on the links for further details.
|BeginFile||Fired before each file is processed.|
|EndFile||Fired after each file is processed.|
|Error||Information about non-fatal errors.|
|Overwrite||Fired whenever a file exists and may be overwritten.|
|Progress||Fired as progress is made.|
The following is a list of configuration settings for the control with short descriptions. Click on the links for further details.
|CheckForFileLocks||If true, the control requests an exclusive lock during initialization.|
|ExcludedAttributes||Attributes of files to be excluded.|
|ExtractFilesOnly||Whether to only extract the files contained within the archive.|
|OverwriteReadonlyFiles||Whether to overwrite readonly files.|
|WriteToProgressEvent||Whether or not to write data to the Progress Event.|
|CodePage||The system code page used for Unicode to Multibyte translations.|
|UseInternalSecurityAPI||Tells the control whether or not to use the system security libraries or an internal implementation.|