Link to home
Start Free TrialLog in
Avatar of dfr031260
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($zip_file_name) != AZ_OK;
ASKER CERTIFIED SOLUTION
Avatar of alskdj80
alskdj80

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dfr031260
dfr031260

ASKER

Thank you.

David