FtpOpenFile (Windows Embedded CE 6.0)
1/6/2010
This function initiates access to a remote file for writing or reading.
Syntax
HINTERNET FtpOpenFile(
HINTERNET hConnect,
LPCTSTR lpszFileName,
DWORD dwAccess,
DWORD dwFlags,
DWORD dwContext
);
Parameters
- hConnect
[in] Valid handle to an FTP session.
- lpszFileName
[in] Long pointer to a null-terminated string that contains the name of the file to access on the remote system.
- dwAccess
[in] Value that determines how the file will be accessed. This can be GENERIC_READ or GENERIC_WRITE, but not both.
dwFlags
[in] Specifies the conditions under which the transfers occur. The application should select one transfer type and flags that control file caching.The following table shows the possible transfer type values. The transfer type can be one of these values.
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.
The following table shows values that are used to control file caching. The application can use one or more of these values.
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. If the INTERNET_FLAG_HYPERLINK is also specified, WinInet will create the cache file but will not commit it.
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.
- dwContext
[in] Specifies an application-defined value that associates this search with application data. This is only used if the application has already called InternetSetStatusCallback to set up a status callback function. All status requests are handled synchronously.
Return Value
A handle indicates success. NULL indicates failure. To get extended error data, call GetLastError.
Remarks
The following list shows situations in which this function should be used:
- An application has data 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 InternetWriteFile to 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 InternetReadFile after using FtpOpenFile to 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 FtpOpenFile and 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 lpszFile parameter 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. FtpOpenFile translates the directory name separators to the appropriate character before they are used.
The InternetCloseHandle function is used to close the handle returned by FtpOpenFile. If InternetCloseHandle closes the handle before all the data has been transferred, the transfer is terminated.
Requirements
Header | wininet.h |
Library | wininet.lib |
Windows Embedded CE | Windows CE 2.0 and later |
See Also
Reference
WinInet Functions
InternetCloseHandle
InternetReadFile
InternetSetStatusCallback
InternetWriteFile