Hi,
You've got to take the result back from the recursion.
try:
bool NameIsInDirectory(const CString& rootPath, const CString& searchName)const
{
bool result = false;
CFileFind finder;
CString folderName;
CString folderPath;
CString strWildcard(rootPath);
strWildcard += _T("\\*.*");
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking && ! result)
{
bWorking = finder.FindNextFile();
if (finder.IsDots())
continue;
if (finder.IsDirectory())
{
CString path = finder.GetFilePath();
CString name = finder.GetFileName();
if(!name.Compare(searchName))
{
result = true;
break;
}
result = NameIsInDirectory(path, searchName);
}
}
finder.Close();
return result;
}.
Next to that you might take a serious look at doing a case sensitive search or not. you could even leave that to the user if you add another bool (ignoreCase) to parameter list.
Hope this works for you.
Cheers, AT