FtpFindFirstFileW

The FtpFindFirstFileW function starts or continues a directory listing on an FTP server.

BOOL FtpFindFirstFileW(
  HINTERNET     hFtpSession,
  LPCTSTR       lpszSearch,
  LPWIN32_FIND_DATA lpFindFileData,
  DWORD         dwFlags,
  DWORD_PTR     dwContext
);

Parameters

  • hFtpSession
    HINTERNET: Handle to an FTP session, obtained from a call to FtpOpenServer.
  • lpszSearch
    LPCTSTR: Pointer to a null-terminated string that specifies the search criteria. This can be a filename or a wildcard pattern. For example, "*.txt" or "data.csv".
  • lpFindFileData
    LPWIN32_FIND_DATA: Pointer to a WIN32_FIND_DATA structure that receives information about the found file or directory.
  • dwFlags
    DWORD: Flags that control the operation. The following values are supported:
    • INTERNET_FLAG_RELOAD: Forces a reload of the resource.
    • INTERNET_FLAG_RESYNCHRONIZE: Reloads the resource if it is not up-to-date.
    • INTERNET_FLAG_WHITE_BACKGROUND: Displays the white background if the resource is a GIF image.
    • INTERNET_FLAG_PRAGMA_NOCACHE: Does not use the cache to satisfy the request.
    • INTERNET_FLAG_DIR_LIST: Returns a directory listing.
  • dwContext
    DWORD_PTR: Application-defined value that is used to identify this data to the application. This parameter is used with asynchronous operations.

Return Value

If the function succeeds, it returns a handle to the first file or directory that matches the search criteria. This handle can be used with subsequent calls to FtpFindNextFileW to retrieve subsequent matches.

If the function fails, it returns NULL. To get extended error information, call GetLastError.

Syntax Example

C++

BOOL FtpFindFirstFileW(
    HINTERNET hFtpSession,
    LPCWSTR lpszSearch,
    LPWIN32_FIND_DATAW lpFindFileData,
    DWORD dwFlags,
    DWORD_PTR dwContext
);

Requirements

SDK: Included in Windows SDK versions for Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2.

DLL: Wininet.lib

Unicode and ANSI versions: The "W" version (wide characters) and "A" version (ANSI characters) of this function are available.