Evgenijm:
Почему максимальная глубина рекурсии 3. и как нам определить поиск по всем каталогам????
bool SearchFileRecursive(const wstring& file, const wstring& directory, wstring& found, int maxdepth, int depth = 0)
{
WIN32_FIND_DATAW fData;
wstring mask = directory + L"\\\\*.*";
HANDLE search = FindFirstFileW(mask.c_str(), &fData);
if (search == INVALID_HANDLE_VALUE) return false;
else
{
do
{
if (!wcscmp(fData.cFileName, L".") || !wcscmp(fData.cFileName, L"..")) continue;
found = directory + L"\\\" + fData.cFileName;
if (file == fData.cFileName)
{
return true;
}
else
if (fData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (depth < maxdepth &&
SearchFileRecursive(file, found, found, maxdepth, depth + 1))
{
return true;
}
}
} while (FindNextFileW(search, &fData));
}
FindClose(search);
return false;
}
void main()
{
const int MAX_RECURSION_DEPTH = 3;
wstring found;
SearchFileRecursive(L"3b.doc", L"d:", found, MAX_RECURSION_DEPTH);*/
}