Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

FTP Download a File with Progress Monitoring

Download Chilkat C/C++ Libraries for VC++ 10.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 10.0 / x64

Download Chilkat C/C++ Libraries for VC++ 9.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 9.0 / x64

Download Chilkat C/C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C/C++ 64-bit Libraries for VC++ 8.0 / x64

Download Chilkat Visual Studio 2005 C/C++ Libs for Windows Mobile, Pocket PC, SmartPhone, WinCE

Download Chilkat C/C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0, Win 95/98/NT4 Compatible

C++ sample program to download a file from an FTP server with progress monitoring callbacks.

// To get FTP progress monitoring callbacks, declare a C++ class
// that inherits from the CkFtpProgress base class and provide
// implementations for FtpPercentDone and AbortCheck.

class MyFtpProgress : public CkFtpProgress
    {
    // pctDone is a percent value between 1 and 100.
    // FtpPercentDone is called each time pctDone increases.
    // The abort argument can be set to cause the FTP to abort while in progress.
    void FtpPercentDone(long pctDone, bool *abort) 
	{ 
	printf("%d Percent Done!\n",pctDone);

	// In this example, the commented-out code will abort the transfer after it is 40% complete.
	//if (pctDone >= 40)
	    //{
	    //*abort = true;
	    //}
	}

    // Called periodically to check to see if the transfer should be aborted.
    void AbortCheck(bool *abort) 
	{ 
	printf("Abort Check!\n");

	// Set the *abort argument to true to force a transfer to abort.
	// For example:
	//*abort = true;
	}

    };


void FtpDownload(void)
    {
    CkFtp2 ftp;
    MyFtpProgress myProgress;

    ftp.UnlockComponent("anything for 30-day trial");

    ftp.put_Hostname("ftp.chilkatsoft.com");
    ftp.put_Username("***");
    ftp.put_Password("***");

    // non-passive (active) connections are most likely to work if firewalls are present.
    // However, if the data connection cannot be established, try switching to Passive mode instead.
    ftp.put_Passive(false);

    // The HeartbeatMs property controls the frequency of AbortCheck callbacks.
    // The default value is 0 (no callbacks).  Set it to a reasonable number of milliseconds:
    ftp.put_HeartbeatMs(250);

    // Some FTP server may require that the AutoGetSizeForProgress property be set to true.
    // Only do this if you see that percent-done progress events are not firing.  
    ftp.put_AutoGetSizeForProgress(true);

    bool success = ftp.Connect();
    if (!success)
	{
	ftp.SaveLastError("ftpLog.txt");
	return;
	}

    // Call GetFile2 to download with progress monitoring.
    // Call GetFile to download without progress monitoring.
    success = ftp.GetFile2("someFile.dat","someFile.dat",myProgress);
    if (!success)
	{
	ftp.SaveLastError("ftpLog.txt");
	}

    ftp.Disconnect();
    }

 

 

 

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Mail Component · XML Parser