Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function initiates access to a remote file for writing or reading.
BOOL WINAPI FtpOpenFile( HINTERNET hConnect , LPCTSTR lpszFileName , DWORD dwAccess , DWORD dwFlags , DWORD dwContext );
Parameters
Value | Description |
---|---|
FTP_TRANSFER_TYPE_ASCII | Transfers the file using FTP ASCII, Type A, transfer method. Control and formatting data is converted to local equivalents. |
FTP_TRANSFER_TYPE_BINARY | Transfers 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_UNKNOWN | Defaults to FTP_TRANSFER_TYPE_BINARY. |
INTERNET_FLAG_TRANSFER_ASCII | Transfers the file as ASCII. |
INTERNET_FLAG_TRANSFER_BINARY | Transfers the file as binary. |
One or more of the values described in the following table are used by an application to control file caching.
Value | Description |
---|---|
INTERNET_FLAG_DONT_CACHE | Does not cache the data, either locally or in gateways. Identical to the preferred value INTERNET_FLAG_NO_CACHE_WRITE. |
INTERNET_FLAG_HYPERLINK | Forces 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_REQUEST | Causes a temporary file to be created if the file cannot be cached. Identical to the preferred value INTERNET_FLAG_NEED_FILE. |
INTERNET_FLAG_NEED_FILE | Causes a temporary file to be created if the file cannot be cached. |
INTERNET_FLAG_NO_CACHE_WRITE | Does not cache the data, either locally or in gateways. |
INTERNET_FLAG_RELOAD | Forces a download of the requested file, object, or directory listing from the origin server, not from the cache. |
INTERNET_FLAG_RESYNCHRONIZE | Causes the FTP resource to be reloaded from the server. |
Return Values
A handle indicates success. NULL indicates failure. To get extended error data, call GetLastError.
Remarks
Inetftp.dll is available only for Intel x86 processors.
FtpOpenFileshould be used in the following situations:
An application has data it needs to send to an FTP server to be created as a file on the FTP server, but the application does not have a local file containing the data. After the file is opened with FtpOpenFile, the application uses InternetWriteFileto send the FTP file data to the server.
An application needs to retrieve a file from the server into application-controlled memory, instead of writing the file to disk. The application uses InternetReadFileafter using FtpOpenFileto open the file.
An application needs a fine level of control over a file transfer. For example, the application may need to display a progress indicator when downloading a file to indicate to the user that the file transfer is, or is not, proceeding correctly.
After calling FtpOpenFileand until calling InternetCloseHandle, all other calls to FTP functions on the same FTP session handle will fail and set the error message to ERROR_FTP_TRANSFER_IN_PROGRESS.
Only one file can be open in a single FTP session. Therefore, no file handle is returned and the application simply uses the FTP session handle when necessary.
The lpszFileparameter 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. FtpOpenFiletranslates the directory name separators to the appropriate character before they are used.
The InternetCloseHandlefunction is used to close the handle returned by FtpOpenFile. If InternetCloseHandlecloses the handle before all the data has been transferred, the transfer is terminated.
Requirements
Runs on | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 2.0 and later | Wininet.h | Wininet.lib |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
GetLastError, InternetCloseHandle, InternetReadFile, InternetSetStatusCallback, InternetWriteFile