Sample code for 30+ languages & platforms
Unicode C

Get the Last-Modified Date/Time for one File by Name

Demonstrates how to get the last-modified date/time for a file on the FTP server by specifying the remote file path.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkFtp2W.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkFtp2W ftp;

    success = FALSE;

    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    ftp = CkFtp2W_Create();

    CkFtp2W_putHostname(ftp,L"ftp.example.com");
    CkFtp2W_putUsername(ftp,L"myLogin");
    CkFtp2W_putPassword(ftp,L"myPassword");
    //  Use explicit TLS
    CkFtp2W_putAuthTls(ftp,TRUE);
    CkFtp2W_putPort(ftp,21);

    //  For debugging, turn on session logging so we can examine what is sent by the server.
    CkFtp2W_putKeepSessionLog(ftp,TRUE);

    //  Connect and login to the FTP server.
    success = CkFtp2W_Connect(ftp);
    if (success == FALSE) {
        wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
        CkFtp2W_Dispose(ftp);
        return;
    }

    CkFtp2W_ChangeRemoteDir(ftp,L"AAWorkarea");

    //  Get the last-modified date/time information for the file "package.tgz"
    wprintf(L"%s\n",CkFtp2W_getLastModifiedTimeByNameStr(ftp,L"package.tgz"));

    //  Show the session log so we can see the details of the date/time information sent by the server.
    //  This tells us what information is available.  Some FTP servers provide better and more accurate information
    //  than others.

    wprintf(L"---- Session Log ----\n");
    wprintf(L"%s\n",CkFtp2W_sessionLog(ftp));

    CkFtp2W_Disconnect(ftp);


    CkFtp2W_Dispose(ftp);

    }