65.9K
CodeProject is changing. Read more.
Home

CCeFileFind - A FileFind class for Windows CE

Aug 22, 2001

CPOL
viewsIcon

102052

downloadIcon

323

CCeFileFind - A FileFind class for Windows CE.

Introduction

This class was originally posted by Waseem Anis on CodeGuru. However after misunderstanding how the class works and finding (and subsequently fixing) several bugs, I decided that Waseem's article and code although excellent, needed some clarification.

As most Windows CE programmers know, Microsoft has not provided a FindFile MFC class to wrap the Windows CE FindFile APIs. This functionality lacking in the Windows CE SDK is provided in the CCeFileFind.

Using the class

The example code below demonstrates using the CeFileFind class to determine the device's storage card directory.

CCeFileFind p_ff;
BOOL bFilesFound =  p_ff.FindFile(_T("\\*"));

while(bFilesFound)
{
    bFilesFound = p_ff.FindNextFile();
    if(p_ff.IsTemporary() && p_ff.IsDirectory())
    {
        m_csDirectoryName = p_ff.GetFileName();
        break;
    }
}

NB. Note how FindFile is executed first, then FindNextFile is executed and then GetFileName is executed. FindFile and FindNextFile must occur in the demonstrated order. Any further questions or queries, feel free to contact me.