FtpOpenFile function
Initiates access to a remote file on an FTP server for reading or writing.
Syntax
HINTERNET FtpOpenFile( _In_ HINTERNET hConnect, _In_ LPCTSTR lpszFileName, _In_ DWORD dwAccess, _In_ DWORD dwFlags, _In_ DWORD_PTR dwContext );
Parameters
- hConnect [in]
-
Handle to an FTP session.
- lpszFileName [in]
-
Pointer to a null-terminated string that contains the name of the file to be accessed.
- dwAccess [in]
-
File access. This parameter can be GENERIC_READ or GENERIC_WRITE, but not both.
- dwFlags [in]
-
Conditions under which the transfers occur. The application should select one transfer type and any of the flags that indicate how the caching of the file will be controlled.
The transfer type can be one of the following values.
The following values are used to control the caching of the file. The application can use one or more of these values.
- dwContext [in]
-
Pointer to a variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called InternetSetStatusCallback to set up a status callback function.
Return value
Returns a handle if successful, or NULL otherwise. To retrieve a specific error message, call GetLastError.
Remarks
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. After the calling application has finished using the HINTERNET handle returned by FtpOpenFile, it must be closed using the InternetCloseHandle function.
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 lpszFileName parameter can be either a partially or fully qualified file name 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.
Requirements
|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names |
FtpOpenFileW (Unicode) and FtpOpenFileA (ANSI) |
See also