Chilkat HOME ASP Visual Basic VB.NET C# C C++ MFC Delphi FoxPro Java Perl Python Ruby SQL Server VBScript
Change a Filename before UnzippingHow to open a zip and modify the filename of one or more files within the zip before unzipping.
<?php $zip = new COM("Chilkat.Zip2"); // Any string unlocks the component for the 1st 30-days. $success = $zip->UnlockComponent('Anything for 30-day trial'); if ($success != true) { print $zip->lastErrorText() . "\n"; exit; } $success = $zip->OpenZip('test.zip'); if ($success != true) { print $zip->lastErrorText() . "\n"; exit; } $entry = $zip->GetEntryByName('hamlet.xml'); // Assume entry is non-null. If GetEntryByName failed // to find the entry, it returns a null reference. $entry->FileName = 'hamlet2.xml'; $entry = $zip->GetEntryByName('helloWorld.pl'); $entry->FileName = 'hw.pl'; // Now unzip to the "test" subdirectory, under our current // working directory: $numFilesUnzipped = $zip->Unzip('test'); if ($numFilesUnzipped < 0) { print $zip->lastErrorText() . "\n"; exit; } // The filenames within the .zip are unchanged, but it unzipped // test/hw.pl and test/hamlet2.xml ?> |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.