Is there a way to unzip just one file from a zip? I'm using code based on response for How to get Inno Setup to unzip a file it installed (all as part of the one installation process), works perfect for unzip but don't have an idea how can it unzip a single file:
[Code]:
const
NO_PROGRESS_BOX = 4;
RESPOND_YES_TO_ALL = 16;
procedure UnZip(ZipPath, TargetPath: string);
var
Shell: Variant;
ZipFile: Variant;
TargetFolder: Variant;
begin
Shell := CreateOleObject('Shell.Application');
ZipFile := Shell.NameSpace(ZipPath);
if VarIsClear(ZipFile) then
RaiseException(Format('ZIP file "%s" does not exist or cannot be opened', [ZipPath]));
TargetFolder := Shell.NameSpace(TargetPath);
if VarIsClear(TargetFolder) then
RaiseException(Format('Target path "%s" does not exist', [TargetPath]));
TargetFolder.CopyHere(ZipFile.Items, NO_PROGRESS_BOX or RESPOND_YES_TO_ALL);
end;
I found a way that works, not what I was expected but is functional.
Use
Folder.ParseName
to retrieve a reference to a specific file in a ZIP archive "folder". Then pass that reference toFolder.CopyHere
to extract it.