FtpGetFile Function  
 
INT WINAPI FtpGetFile(
  HCLIENT hClient,  
  LPCTSTR lpszLocalFile,  
  LPCTSTR lpszRemoteFile,  
  DWORD dwOptions,  
  DWORD dwOffset  
);

The FtpGetFile function transfers the specified file on the server to the local system.

Parameters

hClient
Handle to the client session.
lpszLocalFile
A pointer to a string that specifies the file on the local system that will be created, overwritten or appended to. The file pathing and name conventions must be that of the local host.
lpszRemoteFile
A pointer to a string that specifies the file on the server that will be transferred to the local system. The file naming conventions must be that of the host operating system.
dwOptions
An unsigned integer that specifies one or more options. This parameter may be any one of the following values:
Value Description
FTP_TRANSFER_DEFAULT This option specifies the default transfer mode should be used. If the local file exists, it will be overwritten with the contents of the downloaded file.
FTP_TRANSFER_APPEND This option specifies that if the local file exists, the contents of file on the server is appended to the local file. If the local file does not exist, it is created.
dwOffset
A byte offset which specifies where the file transfer should begin. The default value of zero specifies that the file transfer should start at the beginning of the file. A value greater than zero is typically used to restart a transfer that has not completed successfully. Note that specifying a non-zero offset requires that the server support the REST command to restart transfers.

Return Value

If the function succeeds, the return value is the server result code. If the function fails, the return value is FTP_ERROR. To get extended error information, call FtpGetLastError.

Remarks

This function will cause the current thread to block until the file transfer completes, a timeout occurs or the transfer is canceled. During the transfer, the FTP_EVENT_PROGRESS event will be periodically fired, enabling the application to update any user interface controls. Event notification must be enabled, either by calling FtpEnableEvents, or by registering a callback function using the FtpRegisterEvent function.

To determine the current status of a file transfer while it is in progress, use the FtpGetTransferStatus function.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: csftpv11.lib
Unicode: Implemented as Unicode and ANSI versions

See Also

FtpChangeDirectory, FtpEnableEvents, FtpGetMultipleFiles, FtpGetTransferStatus, FtpPutFile, FtpPutMultipleFiles, FtpRegisterEvent, FtpSetBufferSize, FtpVerifyFile