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
Using the class
The example code below demonstrates using the
CeFileFind class to determine the device's storage card directory.
BOOL bFilesFound = p_ff.FindFile(_T("\\*"));
bFilesFound = p_ff.FindNextFile();
if(p_ff.IsTemporary() && p_ff.IsDirectory())
m_csDirectoryName = p_ff.GetFileName();
NB. Note how
FindFile is executed first, then
FindNextFile is executed and then
GetFileName is executed.
FindNextFile must occur in the demonstrated order. Any further questions or queries, feel free to contact me.