React Native Requires Chilkat v11.0.0+
React Native
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 React Native Downloads
import { Zip, ZipEntry } from '@chilkat/react-native'
async function chilkatExample() {
let success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const zip = new Zip();
try {
await zip.openZipAsync('test.zip');
} catch {
console.log(zip.lastErrorText);
return;
}
const entry = new ZipEntry();
success = zip.entryOf('hamlet.xml', entry);
if (!success) {
console.log(zip.lastErrorText);
return;
}
entry.fileName = 'hamlet2.xml';
success = zip.entryOf('helloWorld.pl', entry);
if (!success) {
console.log(zip.lastErrorText);
return;
}
entry.fileName = 'hw.pl';
// Now unzip to the "test" subdirectory, under our current
// working directory:
const numFilesUnzipped = await zip.unzipAsync('test');
if (numFilesUnzipped < 0) {
console.log(zip.lastErrorText);
return;
}
// The filenames within the .zip are unchanged, but it unzipped
// test/hw.pl and test/hamlet2.xml
}