LInetFtp::LInetFtp

#include "ltwrappr.h"

L_VOID LInetFtp::LInetFtp(L_VOID)

L_VOID LInetFtp::LInetFtp(pszServer, pszUserName = NULL, pszPassword = NULL, nPort = 21)

L_TCHAR L_FAR *pszServer;

/* name of server to connect to */

L_TCHAR L_FAR *pszUserName;

/* username for authentication */

L_TCHAR L_FAR *pszPassword;

/* password for authentication */

L_INT nPort;

/* port number to connect to */

Constructs and initializes the member variables of the LInetFtp object.

Parameter

Description

pszServer

Character string that contains the host name of an FTP server. This can be a URL, like ftp.leadtools.com, or it can contain the IP number of the site, in ASCII dotted-decimal format (for example, 208.35.195.11).

pszUserName

Character string that contains the name of the user logging on. Default value is NULL. This is a NULL-terminated string.

pszPassword

Character string that contains the password to use when logging on. Default value is NULL. This is a NULL-terminated string.

nPort

Number of the TCP/IP port on the server to connect to. These flags set only the port that will be used. Use the default port for FTP servers: INTERNET_DEFAULT_FTP_PORT (port 21).

Returns

None

Comments

LInetFtp::LInetFtp() is the default LInetFtp constructor. After calling the this constructor, a user must call LInetFtp::Connect to establish a connection before using other functions.

LInetFtp::LInetFtp(pszServer, pszUserName = NULL, pszPassword = NULL, nPort = 21) is a constructor for the LInetFtp object. It connects to the FTP server. If both pszUserName and pszPassword are NULL, the connection is made anonymously.

A connection to an FTP server must be established before using any other FTP functions. If a connection is disconnected, via either LInetFtp::Disconnect or LInetFtp::~LInetFtp, then a connection must be re-established before any other FTP functions are called. LInetFtp::Connect and LInetFtp::LInetFtp can be used to establish a connection with an FTP server.

Required DLLs and Libraries

LTFIL
LTWEB

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

LInetFtp::~LInetFtp, LInetFtp::Connect, Class Members

Topics:

FTP Functions: Connect / Disconnect Operations

 

How to Program with the LInetFtp Class

Example

//This example for LInetFtp::LInetFtp(L_VOID)

// This will call the default constructor and destructor when it is out of scope

LInetFtp InetFtp();

// other code

//-----------------------------------------------------------------------------------------------------------------------

/*This example for LInetFtp::LInetFtp(pszServer, pszUserName = NULL, pszPassword = NULL, nPort = 21)*/

// This example simulates storing a file on an FTP server

L_VOID TestFunction(HWND hWndParent, L_TCHAR L_FAR *pszSourceFileName, L_TCHAR L_FAR *pszDistFileName)
{
   LInetFtp InetFtp(TEXT("www.leadtools.com"));

   // Checking if the connection failed
   if(InetFtp.GetErrorFromList () != SUCCESS)
   {
      InetFtp.DisplayError (hWndParent, TEXT("Can't connect to the FTP server"));
      return;
   }

   if(InetFtp.CreateDir (TEXT("MyDirName")) != SUCCESS)
   {
      InetFtp.DisplayError(hWndParent, TEXT("Can't create a directory"));
      return;
   }

   if(InetFtp.SendFile (pszSourceFileName, pszDistFileName, SENDAS_BINARY) != SUCCESS)
   {

      InetFtp.DeleteDir (TEXT("MyDirName"));
      InetFtp.DisplayError (hWndParent, TEXT("Error while send the file"));
      return;
   }
}