Declaration
function ExtractFromStreamZIP(Stream: TStream; SelectedOnly: Boolean; const DestFolder: string; UseFullPath: Boolean = True; const Password: string = ''): Boolean; overload;
function ExtractFromStreamZIP(Stream: TStream; FileIndex: Integer; const DestFolder: string; UseFullPath: Boolean = True; const Password: string = ''): Boolean; overload;
function ExtractFromStreamZIP(Stream: TStream; FileIndexes: TCardinalArray; Count: Integer; const DestFolder: string; UseFullPath: Boolean = True; const Password: string = ''): Boolean; overload;
Description
Extracts one or all files from an archive streamm to the specified folder.
The following archive formats are supported: Zip, ZipX, EPub, 7z, BZip2, Cab, Rar, Tar, ISO, CHM and LZH.
If SelectedOnly = True, the selected files in the associated TImageEnMView will be extracted (selected folders will be ignored). If SelectedOnly = False, all files will be extracted. Otherwise you can specify the indexes of one or more files.
Specify -1 to extract all files, or specify an index of a specific file. The file(s) will be output to the specified folder.
If UseFullPath = False, then all files will be output to the specified folder. If UseFullPath = True, then the folder structure of the zip will be created within the specified path.
If the file is encrypted you can specify the password (otherwise a password prompt can be displayed if you enable
AutoPromptForPassword. You can also use the
OnPassword event).
The result will be False if an error is encountered, e.g. the file in the stream is not a supported format or the
7z plug-in is not found (
Aborting will be True).
Note:
◼Archive extraction requires the
7z plug-in
◼ExtractFromStreamZIP does not reset the position of the stream, so you may need to first call Stream.Position := 0;
◼To abort while extracting set
Aborting to True
◼Read more about
ImageEn ZIP Support
Examples
// Extract all files from a zip (Recreating the internal zip folder structure)
ImageEnMView1.MIO.ExtractFromStreamZIP( Stream, False, 'D:\Out\', True );
// Extract the selected files from a zip
ImageEnMView1.MIO.ExtractFromStreamZIP( Stream, True, 'D:\Out\', False );
// Extract the first file from a zip
ImageEnMView1.MIO.ExtractFromStreamZIP( Stream, 0, 'D:\Out\', False );
// Extract three files from a zip
images[0] := 2;
images[1] := 4;
images[2] := 5;
ImageEnMView1.MIO.ExtractFromStreamZIP( Stream, images, 3, 'D:\Out\', False );