Share via


CFileFind Class

Performs local file searches and is the base class for CGopherFileFind and CFtpFileFind, which perform Internet file searches.

class CFileFind : public CObject

Members

Public Constructors

Name

Description

CFileFind::CFileFind

Constructs a CFileFind object.

Public Methods

Name

Description

CFileFind::Close

Closes the search request.

CFileFind::FindFile

Searches a directory for a specified file name.

CFileFind::FindNextFile

Continues a file search from a previous call to FindFile.

CFileFind::GetCreationTime

Gets the time the file was created.

CFileFind::GetFileName

Gets the name, including the extension, of the found file

CFileFind::GetFilePath

Gets the whole path of the found file.

CFileFind::GetFileTitle

Gets the title of the found file. The title does not include the extension.

CFileFind::GetFileURL

Gets the URL, including the file path, of the found file.

CFileFind::GetLastAccessTime

Gets the time that the file was last accessed.

CFileFind::GetLastWriteTime

Gets the time the file was last changed and saved.

CFileFind::GetLength

Gets the length of the found file, in bytes.

CFileFind::GetRoot

Gets the root directory of the found file.

CFileFind::IsArchived

Determines if the found file is archived.

CFileFind::IsCompressed

Determines if the found file is compressed.

CFileFind::IsDirectory

Determines if the found file is a directory.

CFileFind::IsDots

Determines if the name of the found file has the name "." or "..", indicating that is actually a directory.

CFileFind::IsHidden

Determines if the found file is hidden.

CFileFind::IsNormal

Determines if the found file is normal (in other words, has no other attributes).

CFileFind::IsReadOnly

Determines if the found file is read-only.

CFileFind::IsSystem

Determines if the found file is a system file.

CFileFind::IsTemporary

Determines if the found file is temporary.

CFileFind::MatchesMask

Indicates the desired file attributes of the file to be found.

Protected Methods

Name

Description

CFileFind::CloseContext

Closes the file specified by the current search handle.

Protected Data Members

Name

Description

CFileFind::m_pTM

Pointer to a CAtlTransactionManager object.

Remarks

CFileFind includes member functions that begin a search, locate a file, and return the title, name, or path of the file. For Internet searches, the member function GetFileURL returns the file's URL.

CFileFind is the base class for two other MFC classes designed to search particular server types: CGopherFileFind works specifically with gopher servers, and CFtpFileFind works specifically with FTP servers. Together, these three classes provide a seamless mechanism for the client to find files, regardless of the server protocol, the file type, or location, on either a local machine or a remote server.

The following code will enumerate all the files in the current directory, printing the name of each file:

CFileFind finder;
BOOL bWorking = finder.FindFile(_T("*.*"));
while (bWorking)
{
   bWorking = finder.FindNextFile();
   TRACE(_T("%s\n"), (LPCTSTR)finder.GetFileName());
} 

To keep the example simple, this code uses the standard C++ library cout class. The cout line could be replaced with a call to CListBox::AddString, for example, in a program with a graphical user interface.

For more information about how to use CFileFind and the other WinInet classes, see the article Internet Programming with WinInet.

Inheritance Hierarchy

CObject

CFileFind

Requirements

Header: afx.h

See Also

Reference

CObject Class

Hierarchy Chart

CFtpFileFind Class

CGopherFileFind Class

CInternetFile Class

CGopherFile Class

CHttpFile Class