Sample code for 30+ languages & platforms
Unicode C

Get Last Modified Date/Time of Files in a Remote Directory

Gets the last-modified date/times of files in a remote FTP directory.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkFtp2W.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkFtp2W ftp;
    int n;
    int i;

    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;
    }

    //  Iterate over .txt files.
    CkFtp2W_putListPattern(ftp,L"*.txt");
    n = CkFtp2W_GetDirCount(ftp);
    wprintf(L"n = %d\n",n);

    i = 0;
    while (i < n) {
        wprintf(L"%d: %s, %s\n",i,CkFtp2W_getFilename(ftp,i),CkFtp2W_getLastModifiedTimeStr(ftp,i));
        i = i + 1;
    }

    //  Show the session log so we can see the details of the FTP directory listing 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);

    }