#include <windows.h>
void main()
{
char file[MAX_PATH];
SearchPathA("D:/","3b",".doc", MAX_PATH, file, NULL);
}
#include <windows.h>
#include <string>
#include <cstdio>
using namespace std;
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);
}
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.