Dart Requires Chilkat v11.0.0+
Dart
Change a Filename before Unzipping
See more Zip Examples
How to open a zip and modify the filename of one or more files within the zip before unzipping.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
var success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final zip = CkZip();
try {
zip.openZip('test.zip');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final entry = CkZipEntry();
success = zip.entryOf('hamlet.xml', entry);
if (!success) {
print(zip.lastErrorText);
return;
}
entry.fileName = 'hamlet2.xml';
success = zip.entryOf('helloWorld.pl', entry);
if (!success) {
print(zip.lastErrorText);
return;
}
entry.fileName = 'hw.pl';
// Now unzip to the "test" subdirectory, under our current
// working directory:
final numFilesUnzipped = zip.unzip('test');
if (numFilesUnzipped < 0) {
print(zip.lastErrorText);
return;
}
// The filenames within the .zip are unchanged, but it unzipped
// test/hw.pl and test/hamlet2.xml
}