Sample code for 30+ languages & platforms
Node.js

Transition from SFtp.ReadDir to SFtp.ReadDirListing

Provides instructions for replacing deprecated ReadDir method calls with ReadDirListing.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var sftp = new chilkat.SFtp();

    //  ...
    //  ...

    var handle = sftp.OpenDir(".");
    //  ...
    //  ...

    //  ------------------------------------------------------------------------
    //  The ReadDir method is deprecated:

    // dirObj: SFtpDir
    var dirObj = sftp.ReadDir(handle);
    if (sftp.LastMethodSuccess == false) {
        console.log(sftp.LastErrorText);
        return;
    }

    //  ...
    //  ...

    //  ------------------------------------------------------------------------
    //  Do the equivalent using ReadDirListing.
    //  Your application creates a new, empty SFtpDir object which is passed 
    //  in the last argument and filled upon success.

    var dirOut = new chilkat.SFtpDir();
    success = sftp.ReadDirListing(handle,dirOut);
    if (success == false) {
        console.log(sftp.LastErrorText);
        return;
    }

    //  ...
    //  ...

    sftp.CloseHandle(handle);

}

chilkatExample();