FtpGetFileW function (wininet.h)
Retrieves a file from the FTP server and stores it under the specified file name, creating a new local file in the process.
Syntax
BOOL FtpGetFileW(
[in] HINTERNET hConnect,
[in] LPCWSTR lpszRemoteFile,
[in] LPCWSTR lpszNewFile,
[in] BOOL fFailIfExists,
[in] DWORD dwFlagsAndAttributes,
[in] DWORD dwFlags,
[in] DWORD_PTR dwContext
);
Parameters
[in] hConnect
Handle to an FTP session.
[in] lpszRemoteFile
Pointer to a null-terminated string that contains the name of the file to be retrieved.
[in] lpszNewFile
Pointer to a null-terminated string that contains the name of the file to be created on the local system.
[in] fFailIfExists
Indicates whether the function should proceed if a local file of the specified name already exists. If fFailIfExists is TRUE and the local file exists, FtpGetFile fails.
[in] dwFlagsAndAttributes
File attributes for the new file. This parameter can be any combination of the FILE_ATTRIBUTE_* flags used by the CreateFile function.
[in] dwFlags
Controls 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 application can select one of these transfer type values.
The following flags determine how the caching of this file will be done. Any combination of the following flags can be used with the transfer type flag.
[in] dwContext
Pointer to a variable that contains the application-defined value that associates this search with any application data. This is used only if the application has already called InternetSetStatusCallback to set up a status callback function.
Return value
Returns TRUE if successful, or FALSE otherwise. To get a specific error message, call GetLastError.
Remarks
FtpGetFile 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 dwFlags parameter specifies FTP_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.
Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the constructors and destructors of global objects.
Note
The wininet.h header defines FtpGetFile as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | wininet.h |
Library | Wininet.lib |
DLL | Wininet.dll |