Export (0) Print
Expand All

CFileFind Class

class CFileFind : public CObject

Remarks

The MFC class CFileFind performs local file searches and is the base class for CGopherFileFind and CFtpFileFind, which perform Internet file searches. 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("*.*");
   while (bWorking)
   {
      bWorking = finder.FindNextFile();
      cout << (LPCTSTR) finder.GetFileName() << endl;
   }

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.

Requirements

Header: afx.h

See Also

Class Members | Base Class | Hierarchy Chart | CFtpFileFind | CGopherFileFind | CInternetFile | CGopherFile | CHttpFile

Show:
© 2015 Microsoft