Sample code for 30+ languages & platforms
Unicode C

FTP Bandwidth Throttle for Upload

See more FTP Examples

Demonstrates the Chilkat FTP2 upload bandwidth throttling property : BandwidthThrottleUp.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkFtp2W.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkFtp2W ftp;
    const wchar_t *localFilename;
    const wchar_t *remoteFilename;

    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"login");
    CkFtp2W_putPassword(ftp,L"password");

    // To use FTP upload bandwidth throttling, set the BandwidthThrottleUp
    // property to a maximum desired bytes/second:
    // This example limits the upload to 10K per second.
    CkFtp2W_putBandwidthThrottleUp(ftp,10000);

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

    // Upload a file.
    localFilename = L"hamlet.xml";
    remoteFilename = L"hamlet.xml";

    success = CkFtp2W_PutFile(ftp,localFilename,remoteFilename);
    if (success != TRUE) {
        wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
        CkFtp2W_Dispose(ftp);
        return;
    }

    success = CkFtp2W_Disconnect(ftp);

    wprintf(L"File Uploaded!\n");


    CkFtp2W_Dispose(ftp);

    }