Xceed FTP Library Documentation
Sending Files ATL example
Example topics > Sending Files ATL example

This example demonstrates the 7 following steps for receiving files:  

  1. Specify the FTP server's address 
  2. Specify the username to login 
  3. Specify the password for the username 
  4. Connect to the FTP server 
  5. Send files 
  6. Disconnect from the FTP server 
  7. Perform error handling  

NOTE: The code below considers that you are using the #import  compiler directive (included in the code below) 

ATL Copy Code

#import "XceedFtp.dll" named_guids no_namespace

int main(int argc, char* argv[])
{
   CoInitialize( NULL );

   try // step (7)
   {
IXceedFtpPtr piXceedFtp( CLSID_XceedFtp );
      piXceedFtp->License( _bstr_t( L"your license key ) );

      piXceedFtp->ServerAddress = "ftp.cdrom.com"; // step (1)
      piXceedFtp->UserName = "anonymous"; // step (2)
      piXceedFtp->Password = "guest"; // step (3)

      piXceedFtp->Connect();
      printf( "Successfully connected to server. Starting upload.\n" );

      try // step (7)
      {
         piXceedFtp->SendFile( "c:\\to upload\\file.dat", 0, "incoming\\file.dat", FALSE ); //(5)

         // Use the SendMultipleFiles method if you want to use
         // wildcards to send more than one file at a time.

         printf( "Successfully uploaded the file.\n" );
      }
      catch( const _com_error& xErr )
      {
         printf("Upload error: %s\n", ( const WCHAR* ) xErr.Description() );
      }

      piXceedFtp->Disconnect(); // step (6)
   }
   catch( const _com_error& xErr )
   {
      printf( "Connect error: %s\n", ( const WCHAR* ) xErr.Description() );
   }
   catch( ... )
   {
      printf( "An unknown error occurred.\n" );
   }

   CoUninitialize();
   return 0;
}