Searches the specified directory of the given FTP session. File and directory entries are returned to the application in the
WIN32_FIND_DATA structure.
Syntax
HINTERNET FtpFindFirstFile(
__in HINTERNET hConnect,
__in LPCTSTR lpszSearchFile,
__out LPWIN32_FIND_DATA lpFindFileData,
__in DWORD dwFlags,
__in DWORD_PTR dwContext
);
Parameters
- hConnect [in]
-
Handle to an FTP session returned from
InternetConnect.
- lpszSearchFile [in]
-
Pointer to a null-terminated string that specifies a valid directory path or file name for the FTP server's file system. The string can contain wildcards, but no blank spaces are allowed. If the value of
lpszSearchFile is NULL or if it is an empty string, the function finds the first file in the current directory on the server.
- lpFindFileData [out]
-
Pointer to a
WIN32_FIND_DATA structure that receives information about the found file or directory.
- dwFlags [in]
-
Controls the behavior of this function. This parameter can be a combination of the following values.
INTERNET_FLAG_HYPERLINK
INTERNET_FLAG_NEED_FILE
INTERNET_FLAG_NO_CACHE_WRITE
INTERNET_FLAG_RELOAD
INTERNET_FLAG_RESYNCHRONIZE
- dwContext [in]
-
Pointer to a variable that specifies the application-defined value that associates this search with any application data. This parameter is used only if the application has already called
InternetSetStatusCallback to set up a status callback function.
Return Value
Returns a valid handle for the request if the directory enumeration was started successfully, or returns NULL otherwise. To get a specific error message, call
GetLastError. If GetLastError returns ERROR_INTERNET_EXTENDED_ERROR, as in the case where the function finds no matching files, call the
InternetGetLastResponseInfo function to retrieve the extended error text, as documented in Handling Errors.
Remarks
For
FtpFindFirstFile, file times returned in the
WIN32_FIND_DATA structure are in the local time zone, not in a coordinated universal time (UTC) format.
FtpFindFirstFile is similar to the FindFirstFile function. Note, however, that only one
FtpFindFirstFile can occur at a time within a given FTP session. The enumerations, therefore, are correlated with the FTP session handle. This is because the FTP protocol allows only a single directory enumeration per session.
After calling
FtpFindFirstFile and until calling
InternetCloseHandle, the application cannot call
FtpFindFirstFile again on the given FTP session handle. If a call is made to
FtpFindFirstFile on that handle, the function fails with
ERROR_FTP_TRANSFER_IN_PROGRESS. After the calling application has finished using the
HINTERNET handle returned by
FtpFindFirstFile, it must be closed using the
InternetCloseHandle function.
After beginning a directory enumeration with
FtpFindFirstFile, the
InternetFindNextFile function can be used to continue the enumeration.
Because the FTP protocol provides no standard means of enumerating, some of the common information about files, such as file creation date and time, is not always available or correct. When this happens,
FtpFindFirstFile and
InternetFindNextFile fill in unavailable information with a best guess based on available information. For example, creation and last access dates are often the same as the file's modification date.
The application cannot call
FtpFindFirstFile between calls to
FtpOpenFile and
InternetCloseHandle.
Requirements
| Client | Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Me, Windows 98, or Windows 95. |
| Server | Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0. |
|---|
| Version | Requires Internet Explorer 3.0 or later. |
| Header | Declared in Wininet.h. |
| Library | Use Wininet.lib. |
| DLL | Requires Wininet.dll. |
| Unicode/ANSI | Implemented as FtpFindFirstFileW (Unicode) and FtpFindFirstFileA (ANSI). |
See Also
FTP Sessions
WinINet Functions
Send comments about this topic to Microsoft
Build date: 10/2/2008