CFtpQueue::GetFile Method  
 
BOOL GetFile(
  LPCTSTR lpszFileName,  
  LPFTPQUEUEDFILE lpFileInfo  
);
BOOL GetFile(
  DWORD dwFileId,  
  LPFTPQUEUEDFILE lpFileInfo  
);

The GetFile method returns information about the specified file in the transfer queue.

Parameters

lpszFileName
A null-terminated string which specifies the name of the file in the queue. The name should always be the name of the remote file to search for.
dwFileId
An unsigned integer value which uniquely identifies the file in the queue. This value cannot be zero.
lpFileInfo
A pointer to a FTPQUEUEDFILE structure which will contain information about the file. This parameter cannot be NULL.

Return Value

If the method succeeds, the return value is non-zero. If the file identifier is not valid or the file has been removed from the queue, the return value is zero. To get extended error information, call FtpGetLastError.

Remarks

The file identifier can be obtained by several different methods, including EnumFiles and GetStatus, which provides information about the current file being processed in the queue. Do not make any assumptions about the value of the identifier. Although the value is guaranteed to be unique for the specified queue, it is not guaranteed that file identifiers will be assigned in sequential order.

If you call the version of this method which accepts a file name, it will use the FindFile method to obtain the file ID for the first file name which matches a remote file in the queue. This approach is only recommended if you know that the queued file names will be unique.

Example

// Get the number of files in the queue
LONG nFiles = pQueue->GetCount();

// Display information about the queued files
if (nFiles > 0)
{
    DWORD *pdwFileList = new DWORD[nFiles];

    nFiles = pQueue->EnumFiles(pdwFileList, nFiles);

    for (LONG nIndex = 0; nIndex < nFiles; nIndex++)
    {
        FTPQUEUEDFILE queuedFile;

        if (pQueue->GetFile(pdwFileList[nIndex], &queuedFile) == FALSE)
            break;
            
        switch (queuedFile.dwMode)
        {
        case FTP_QUEUE_DOWNLOAD:
               _tprintf(_T("%u: Download \"%s\" to \"%s\"\n"),
                        queuedFile.dwFileId,
                        queuedFile.szRemoteFile,
                        queuedFile.szLocalFile);
                break;

        case FTP_QUEUE_UPLOAD:
               _tprintf(_T("%u: Upload \"%s\" to \"%s\"\n"),
                        queuedFile.dwFileId,
                        queuedFile.szLocalFile,
                        queuedFile.szRemoteFile);
                break;
        }
    }
    
    delete pdwFileList;
}

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csftpv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also