FtpGetFirstFile Function  
 
BOOL WINAPI FtpGetFirstFile(
  HCLIENT hClient,  
  LPFTPFILESTATUS lpFileStatus  
);

The FtpGetFirstFile function returns the first file in the directory listing returned by the server after a call to the FtpOpenDirectory function.

Parameters

hClient
Handle to the client session.
lpFileStatus
A pointer to an FTPFILESTATUS structure which contains information about the file returned by the server.

Return Value

If the function succeeds, the return value is non-zero. If the function fails, the return value is zero. To get extended error information, call FtpGetLastError.

Remarks

This file list information returned by the server is cached by the library, allowing you to use this function to reposition back to the beginning of the file list.

Example

if (FtpOpenDirectory(hClient, _T("")) != FTP_ERROR)
{
    FTPFILESTATUS ftpFile;
    BOOL bResult;

    bResult = FtpGetFirstFile(hClient, &ftpFile);
    while (bResult)
    {
        // The ftpFile structure contains information about the file
        bResult = FtpGetNextFile(hClient, &ftpFile);
    }

    FtpCloseDirectory(hClient);
}

Requirements

Client: Requires Windows 7, Windows Vista or Windows XP.
Server: Requires Windows Server 2008 or Windows Server 2003.
Header: Include cstools7.h.
Library: Use csftpav7.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

FtpCloseDirectory, FtpGetDirectoryFormat, FtpGetFileStatus, FtpGetNextFile, FtpOpenDirectory, FtpSetDirectoryFormat