FtpGetFile() from MSDN

FtpGetFile

This function retrieves a file from the FTP server and stores it under the specified file name, creating a new local file in the process.

 
BOOL WINAPI FtpGetFile(
  HINTERNET hConnect, 
  LPCTSTR lpszRemoteFile, 
  LPCTSTR lpszNewFile, 
  BOOL fFailIfExists, 
  DWORD dwFlagsAndAttributes, 
  DWORD dwFlags, 
  DWORD dwContext
);
Parameters
hConnect
[in] Valid handle to an   FTP  session.
lpszRemoteFile
[in] Long pointer to a null-terminated string that contains the   file  name to retrieve from the remote system.
lpszNewFile
[in] Long pointer to a null-terminated string that contains the   file  name to create on the local system.
fFailIfExists
[in] Boolean that specifies if the function should proceed if a local   file  of the specified name already exists. If   fFailIfExists  is TRUE and the local   fileexists,   FtpGetFile  fails.
dwFlagsAndAttributes
[in] Specifies the   file  attributes for the new   file. Can be a combination of the   FILE_ATTRIBUTE_* flags used by the   CreateFile  function.
dwFlags
[in] Specifies how the function will handle the   file  download. The first set of flag values indicates the conditions under which the transfer occurs. These transfer type flags can be used in combination with the second set of flags that control caching. The following table shows the transfer type values. The application can select one of these values.
ValueDescription
FTP_TRANSFER_TYPE_ASCIITransfers the file using FTP ASCII, Type A, transfer method. Control and formatting data is converted to local equivalents.
FTP_TRANSFER_TYPE_BINARYTransfers the file using FTP Image, Type I, transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method.
FTP_TRANSFER_TYPE_UNKNOWNDefaults to FTP_TRANSFER_TYPE_BINARY.
INTERNET_FLAG_TRANSFER_ASCIITransfers the file as ASCII.
INTERNET_FLAG_TRANSFER_BINARYTransfers the file as binary.

The following flags determine how the file caching will be done. A combination of the following flags can be used with the transfer type flag. Possible values are described in the following table.

The following table shows the flags that determine how file caching will occur. A combination of these flags can be used with the transfer type flags described in the previous table.

FlagDescription
INTERNET_FLAG_DONT_CACHEDoes not add the returned entity to the cache. Identical to the preferred value INTERNET_FLAG_NO_CACHE_WRITE.
INTERNET_FLAG_HYPERLINKForces a reload if there was no Expires time and no Last-Modified time returned by the server when determining whether to reload the item from the network.
INTERNET_FLAG_MUST_CACHE_REQUESTCauses a temporary file to be created if the file cannot be cached. Identical to the preferred value INTERNET_FLAG_NEED_FILE.
INTERNET_FLAG_NEED_FILECauses a temporary file to be created if the file cannot be cached.
INTERNET_FLAG_NO_CACHE_WRITEDoes not add the returned entity to the cache. If the INTERNET_FLAG_HYPERLINK is also specified, WinInet will create the cache file but will not commit it.
INTERNET_FLAG_RELOADForces a download of the requested file, object, or directory listing from the origin server, not from the cache.
INTERNET_FLAG_RESYNCHRONIZECauses the FTP resource to be reloaded from the server.
dwContext
[in] Specifies an application-defined value that associates this search with application data. This is used only if the application has already called >InternetSetStatusCallback to set up a status callback function. All status requests are handled synchronously.
Return Values

TRUE indicates success. FALSE indicates failure. To get extended error data, call >GetLastError.

Remarks

This function is a high-level routine that handles all the bookkeeping and overhead associated with reading a file from an FTP server and storing it locally. An application that needs to retrieve file data only or that requires close control over the file transfer should use the FtpOpenFile and InternetReadFile functions.

If the dwTransferType parameter specifies FILE_TRANSFER_TYPE_ASCII, translation of the file data converts control and formatting characters to local equivalents. The default transfer is binary mode, where the file is downloaded in the same format as it is stored on the server.

Both lpszRemoteFile and lpszNewFile can be either partially or fully qualified file names relative to the current directory. A backward slash (/) or forward slash (/) can be used as the directory separator for either name. FtpGetFile translates the directory name separators to the appropriate character before they are used.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值