CFtpQueue::FindFile Method  
 
DWORD FindFile(
  LPCTSTR lpszFileName,  
  DWORD dwQueueMode,  
  DWORD dwExcludeFiles  
);

The FindFile method finds a file in the transfer queue which matches the search criteria.

Parameters

lpszFileName
A null-terminated string which specifies the name of the file to search for. The string may contain the wildcard character '?' to match against any single character, and '*' will match any number of characters. This parameter cannot be NULL or point to an empty string.
dwQueueMode
An unsigned integer value which specifies if the file name should be matched against downloaded files, uploaded files or all files in the queue. This is a bitmask which may be one or more of the following values:
Constant Description
FTP_QUEUE_ALL Match the file name to all files in the queue.
FTP_QUEUE_DOWNLOAD Match file names which are queued for download.
FTP_QUEUE_UPLOAD Match file names which are queued for upload.
FTP_QUEUE_LOCAL Match against the local file name instead of the remote file name.
dwExcludeFiles
An unsigned integer value which specifies which files to exclude from the search. If this value is zero, no files will be excluded from the search; otherwise, this value is constructed by using a bitwise operator with any of the following values:
Value Description
FTP_QUEUE_FLAG_NONE No files should be excluded from the search.
FTP_QUEUE_FLAG_COMPLETED Exclude files which have been transferred. This flag is set after a queued file has been uploaded or downloaded successfully.
FTP_QUEUE_FLAG_FAILED Exclude files which where not successfully uploaded or downloaded. This flag is set when an error occurs, either when establishing a connection with the server or during the file transfer.
FTP_QUEUE_FLAG_CANCELED Exclude files which were canceled during the file transfer. This flag is only set when the Cancel method has been called and a queued file is in the process of being uploaded or downloaded.

Return Value

If the method succeeds, the return value is a unique identifier for the file. To obtain information about the file, call the GetFile method. If the method fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

This method returns a unique file identifier for the first file which matches the specified file name in the queue. If the lpszFileName parameter includes wildcard characters, this method will return the first file in the queue which matches the name. File name matches are not case-sensitive, even when matching against remote file names on servers which use case-sensitive naming, such as UNIX based servers.

To perform more complex searches based on the file name, or to find multiple files, you can use the GetFirstFile and GetNextFile methods to iterate through all queued files.

Example

// Find a local file in the download queue
DWORD dwFileId = pQueue->FindFile(lpszFileName,
                                  FTP_QUEUE_DOWNLOAD | FTP_QUEUE_LOCAL,
                                  FTP_QUEUE_FLAG_NONE);

// Display information about the queued file
if (dwFileId != 0)
{
    FTPQUEUEDFILE queuedFile;

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

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

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