LInetFtp::GetFile

#include "ltwrappr.h"

L_INT LInetFtp::GetFile(pszRemote, pszLocal, uSendAs, bOverwrite = TRUE)

L_TCHAR *pszRemote;

/* name of the file to retrieve */

L_TCHAR *pszLocal;

/* name of the file to create */

L_UINT uSendAs;

/* file transfer flag */

L_BOOL bOverwrite;

/* file overwriting flag */

Retrieves a file from the FTP server and stores it under the specified file name, locally.

Parameter

Description

pszRemote

Character string that contains the name of the file to retrieve from the FTP server. This is a NULL-terminated string.

pszLocal

Character string that contains the name of the file to create on the local system. This is a NULL-terminated string.

uSendAs

Flag that indicates the conditions under which the transfers occur. Possible values are:

 

Value

Meaning

 

SENDAS_ASCII

Transfers the file as ASCII

 

SENDAS_BINARY

Transfers the file as BINARY

bOverwrite

Boolean flag that indicates whether the function should proceed if a local file of the specified name already exists. Possible values are:

 

Value

Meaning

 

TRUE

The local file will be overwritten.

 

FALSE

If the file already exists locally, then do not store the file locally.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

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::SendFile, LInetFtp::RenameFile, LInetFtp::RemoveFile, Class Members

Topics:

FTP Functions: Remote File Operations

 

How to Program with the LInetFtp Class

Example

This example gets a remote file from an FTP server.

L_INT LInetFtp_GetFileExample(HWND hWndParent, L_TCHAR *pszRemote, L_TCHAR *pszLocal)
{
   L_INT nRet;
   LInetFtp InetFtp(TEXT("www.leadtools.com"));
   // Checking if the connection failed
   nRet = InetFtp.GetErrorFromList ();
   if(nRet != SUCCESS)
   {
      InetFtp.DisplayError (hWndParent, TEXT("Can't connect to the FTP server"));
      return nRet;
   }
   nRet = InetFtp.GetFile(pszRemote, pszLocal, SENDAS_BINARY);
   if(nRet != SUCCESS)
   {
      InetFtp.DisplayError(hWndParent, TEXT("Can't get a remote file, an error within the server"));
      return nRet;
   }
   return SUCCESS;
}