CFileFind Class

The structure used for this class is CFileFind

Quick Ref

void CFileFind::CFileFind()

virtual void CFileFind::~CFileFind()

void CFileFind::Close()

virtual void CFileFind::CloseContext()

virtual int CFileFind::FindFile(const char* pstrName, unsigned long __formal)

virtual int CFileFind::FindNextFileA()

virtual CString CFileFind::GetFileName()

virtual CString CFileFind::GetFilePath()

virtual CString CFileFind::GetFileTitle()

virtual CString CFileFind::GetFileURL()

unsigned long CFileFind::GetLength()

virtual void CFileFind::GetNameAndExt(CString& name, CString& ext)

virtual CString CFileFind::GetRoot()

virtual int CFileFind::IsDots()

virtual int CFileFind::MatchesMask(unsigned long dwMask)


Constructors

Name

Description

CFileFind::CFileFind

Constructs a CFileFind object

CFileFind::~CFileFind

Destroys a CFileFind object

CFileFind::CFileFind

Constructs a CFileFind object

void CFileFind::CFileFind();

Remarks

Constructs a CFileFind object


CFileFind::~CFileFind

Destroys the CFileFind object

virtual void CFileFind::~CFileFind();

Remarks

Destroys the CFileFind object


Methods

Name

Description

CFileFind::Close

Closes the search request

CFileFind::CloseContext

Closes the search request

CFileFind::FindFile

Searches a directory for a specified file name

CFileFind::FindNextFileA

Continues a file search from a previous call to FindFile

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::GetLength

Gets the length of the found file, in bytes

CFileFind::GetNameAndExt

Gets the title and extension of the found file

CFileFind::GetRoot

Gets the root directory of the found file

CFileFind::IsDots

Determines if the name of the found file has “.” or “..”, indicating a directory

CFileFind::MatchesMask

Indicates the desired file attributes of the file to be found

CFileFind::Close

Closes the search request. Call this member function to end the search, reset the context, and release all resources.

void CFileFind::Close();

Remarks

After calling Close, you do not have to create a new CFileFind instance before calling CFileFind::FindFile to begin a new search.


CFileFind::CloseContext

Closes the file specified by the current search handle

virtual void CFileFind::CloseContext();

Remarks

Closes the file specified by the current value of the search handle


CFileFind::FindFile

Searches a directory for a specified file name

virtual int CFileFind::FindFile(
   const char* pstrName,
   unsigned long __formal);

Parameters

  • const char* pstrName - A pointer to a string containing the name of the file to find. If you pass NULL for pstrName, FindFile does a wildcard (*.*) search.

  • unsigned long __formal - Reserved - Must be 0

Return Value

Nonzero if successful; otherwise 0

Remarks

After calling CFileFind::FindFile to begin the file search, call CFileFind::FindNextFileA to retrieve subsequent files. You must call CFileFind::FindNextFileA at least once before calling any of the following attribute member functions:


CFileFind::FindNextFileA

Continues a file search from a previous call to CFileFind::FindFile

virtual int CFileFind::FindNextFileA();

Return Value

Nonzero if there are more files; zero if the file found is the last one in the directory or if an error occurred

Remarks

You must call CFileFind::FindNextFileA at least once before calling any of the following attribute member functions:


CFileFind::GetFileName

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

virtual CString CFileFind::GetFileName();

Return Value

Returns a CString containg the name of the most-recently-found file

Remarks

You must call CFileFind::FindNextFileA at least once before calling CFileFind::GetFileName


CFileFind::GetFilePath

Gets the whole path of the found file

virtual CString CFileFind::GetFilePath();

Return Value

Returns a CString containing the path of the specified file

Remarks

You must call CFileFind::FindNextFileA at least once before calling CFileFind::GetFilePath


CFileFind::GetFileTitle

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

virtual CString CFileFind::GetFileTitle();

Return Value

Returns a CString containing the title of the file

Remarks

You must call CFileFind::FindNextFileA at least once before calling CFileFind::GetFileTitle


CFileFind::GetFileURL

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

virtual CString CFileFind::GetFileURL();

Return Value

Returns a CString containing the complete URL

Remarks

You must call CFileFind::FindNextFileA at least once before calling CFileFind::GetFileURL


CFileFind::GetLength

Gets the length of the found file, in bytes

unsigned long CFileFind::GetLength();

Return Value

The length of the found file, in bytes

Remarks

You must call CFileFind::FindNextFileA at least once before calling CFileFind::GetLength


CFileFind::GetNameAndExt

Gets the title and extension of the found file

virtual void CFileFind::GetNameAndExt(
   CString& name,
   CString& ext);

Parameters

  • CString& name - address of variable to hold file name

  • CString& ext - address of variable to file extension

Remarks

You must call CFileFind::FindNextFileA at least once before calling CFileFind::GetNameAndExt


CFileFind::GetRoot

Gets the root directory of the found file

virtual CString CFileFind::GetRoot();

Return Value

Returns a CString containing the root of the active search

Remarks

You must call CFileFind::FindNextFileA at least once before calling CFileFind::GetRoot


CFileFind::IsDots

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

virtual int CFileFind::IsDots();

Return Value

Nonzero if the found file has the name “.” or “..”, which indicates that the found file is actually a directory. Otherwise 0

Remarks

You must call CFileFind::FindNextFileA at least once before calling CFileFind::IsDots


CFileFind::MatchesMask

Indicates the desired file attributes of the file to be found

virtual int CFileFind::MatchesMask(unsigned long dwMask);

Parameters

  • unsigned long dwMask - Specifies one or more file attributes for the found file

Return Value

Nonzero if successful; otherwise 0

Remarks

You must call CFileFind::FindNextFileA at least once before calling CFileFind::MatchesMask