React Native
React Native
Create Self-Extracting Executable (Windows-only)
Demonstrates how to create a Windows self-extracting EXE.Chilkat React Native Downloads
import { Zip } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const zip = new Zip();
// Chilkat for React Native has no AbortCheck callback. To cancel a pending ...Async call,
// call zip.abort() (Chilkat notices it within heartbeatMs milliseconds); the promise then rejects.
// Called with the percent completed (0..100) while an ...Async method runs.
zip.onPercentDone = (pctDone) => {
console.log(`Percent Done: ${pctDone}`);
// Explicitly abort at 25% or greater.
// Remove this to allow for the HTTP download to run to completion.
if (pctDone > 25) {
zip.abort(); // cancel the Chilkat method in progress
}
};
zip.onProgressInfo = (name, value) => {
console.log(`${name}: ${value}`);
};
// Initialize the zip object. Because we're creating
// a self-extracting EXE in this example, the filename
// passed to NewZip will never actually be created.
try {
zip.newZip('notUsed.zip');
} catch {
console.log(zip.lastErrorText);
return;
}
// Append a directory tree. The AppendFiles does
// not read the file contents or append them to the zip
// object in memory. It simply appends references
// to the files so that when WriteExe (or WriteZipAndClose,
// or WriteZip, etc.) is called, the files are compressed
// and added to the archive.
const recurse = true;
await zip.appendFilesAsync('c:/temp/a/*', recurse);
// Write "sfx.exe"
try {
await zip.writeExeAsync('c:/temp/sfx.exe');
} catch {
console.log(zip.lastErrorText);
return;
}
}