dfr031260
asked on
Add to a already existing Zip file
The following code is fine for creating a new zip file and adding files to it, but how does one add files to an already existing Zip file?
$zip_dir='c:\temp\test';
$zip_file_name='file.zip';
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
## Read names of all files in the directory
@files=<$zip_dir/*>;
my $zip = Archive::Zip->new();
my $member = $zip->addDirectory( $zip_dir);
foreach (@files){ ## Add each file in that directory to the .zip archive.
$member = $zip->addFile($_);
}
die 'Cannot create $zip_file_name: $!\n' if $zip->writeToFileNamed($zi p_file_nam e) != AZ_OK;
$zip_dir='c:\temp\test';
$zip_file_name='file.zip';
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
## Read names of all files in the directory
@files=<$zip_dir/*>;
my $zip = Archive::Zip->new();
my $member = $zip->addDirectory( $zip_dir);
foreach (@files){ ## Add each file in that directory to the .zip archive.
$member = $zip->addFile($_);
}
die 'Cannot create $zip_file_name: $!\n' if $zip->writeToFileNamed($zi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
David