description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CFtpFileFind Class |
CFtpFileFind Class |
05/28/2020 |
|
|
9667cf01-657f-4b11-b9db-f11e5a7b4e4c |
Aids in Internet file searches of FTP servers.
class CFtpFileFind : public CFileFind
Name | Description |
---|---|
CFtpFileFind::CFtpFileFind | Constructs a CFtpFileFind object. |
Name | Description |
---|---|
CFtpFileFind::FindFile | Finds a file on an FTP server. |
CFtpFileFind::FindNextFile | Continues a file search from a previous call to FindFile. |
CFtpFileFind::GetFileURL | Gets the URL, including path, of the found file. |
CFtpFileFind
includes member functions that begin a search, locate a file, and return the URL or other descriptive information about the file.
Other MFC classes designed for Internet and local file searched include CGopherFileFind and CFileFind. Together with CFtpFileFind
, these classes provide a seamless mechanism for the client to find specific files, regardless of the server protocol or file type (either a local machine or a remote server). There's no MFC class for searching on HTTP servers because HTTP doesn't support the direct file manipulation required for searches.
For more information about how to use CFtpFileFind
and the other WinInet classes, see the article Internet Programming with WinInet.
The following code demonstrates how to enumerate all files in the current directory of the FTP server.
[!code-cppNVC_MFCWinInet#8]
CFtpFileFind
Header: afxinet.h
This member function is called to construct a CFtpFileFind
object.
explicit CFtpFileFind(
CFtpConnection* pConnection,
DWORD_PTR dwContext = 1);
pConnection
A pointer to a CFtpConnection
object. You can obtain an FTP connection by calling CInternetSession::GetFtpConnection.
dwContext
The context identifier for the CFtpFileFind
object. For more information, see the following remarks.
The default value for dwContext is sent by MFC to the CFtpFileFind
object from the CInternetSession object that created the CFtpFileFind
object. You can override the default to set the context identifier to a value of your choosing. The context identifier is returned to CInternetSession::OnStatusCallback to provide status on the object with which it's identified. See the article Internet First Steps: WinInet for more information about the context identifier.
See the example in the class overview earlier in this topic.
Call this member function to find an FTP file.
virtual BOOL FindFile(
LPCTSTR pstrName = NULL,
DWORD dwFlags = INTERNET_FLAG_RELOAD);
pstrName
A pointer to a string containing the name of the file to find. If NULL, the call will do a wildcard search (*).
dwFlags
The flags describing how to handle this session. These flags can be combined with the bitwise OR operator (|
) and are as follows:
-
INTERNET_FLAG_RELOAD
Get the data from the wire even if it's locally cached. This is the default flag. -
INTERNET_FLAG_DONT_CACHE
Don't cache the data, either locally or in any gateways. -
INTERNET_FLAG_RAW_DATA
Override the default to return the raw data ( WIN32_FIND_DATA structures for FTP). -
INTERNET_FLAG_SECURE
Secures transactions on the wire with Secure Sockets Layer or PCT. This flag applies to HTTP requests only. -
INTERNET_FLAG_EXISTING_CONNECT
If possible, reuse the existing connections to the server for newFindFile
requests instead of creating a new session for each request.
Nonzero if successful; otherwise 0. To get extended error information, call the Win32 function GetLastError.
After calling FindFile
to retrieve the first FTP file, you can call FindNextFile to retrieve subsequent FTP files.
See the earlier example in this topic.
Call this member function to continue a file search begun with a call to the FindFile member function.
virtual BOOL FindNextFile();
Nonzero if there are more files; zero if the file found is the last one in the directory or if an error occurred. To get extended error information, call the Win32 function GetLastError. If the file found is the last file in the directory, or if no matching files can be found, the GetLastError
function returns ERROR_NO_MORE_FILES.
You must call this function at least once before calling any attribute function (see CFileFind::FindNextFile).
FindNextFile
wraps the Win32 function FindNextFile.
See the example earlier in this topic.
Call this member function to get the URL of the specified file.
CString GetFileURL() const;
The file and path of the Universal Resource Locator (URL).
GetFileURL
is similar to the member function CFileFind::GetFilePath except that it provides the result in URL format. As with CFileFind::GetFilePath
, the result doesn't include the filename. For example, file1.txt
located in //moose/dir/file1.txt:
returns ftp://moose/dir/
.
CFileFind Class
Hierarchy Chart
CGopherFileFind Class
CInternetFile Class
CGopherFile Class
CHttpFile Class