Sample code for 30+ languages & platforms
Node.js

Transition from Zip.AppendOneFileOrDir to Zip.AddFile

Provides instructions for replacing deprecated AppendOneFileOrDir method calls with AddFile.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var zip = new chilkat.Zip();

    // ...
    // ...
    var localFilePath = "c:/someDir/example.dat";
    var saveExtraPath = false;

    // ------------------------------------------------------------------------
    // The AppendOneFileOrDir method is deprecated:

    // entryObj: ZipEntry
    var entryObj = zip.AppendOneFileOrDir(localFilePath,saveExtraPath);
    if (zip.LastMethodSuccess == false) {
        console.log(zip.LastErrorText);
        return;
    }

    // ...
    // ...

    // ------------------------------------------------------------------------
    // Do the equivalent using AddFile.

    // Instead of returning the zip entry object, we just return success/failure.
    success = zip.AddFile(localFilePath,saveExtraPath);
    if (success == false) {
        console.log(zip.LastErrorText);
        return;
    }

    // Do the following if you need the zip entry object for what was just appended.
    // The newly appended entry is the last one.
    var ze = new chilkat.ZipEntry();
    var index = zip.NumEntries - 1;
    zip.EntryAt(index,ze);

}

chilkatExample();