Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wstring FolderPathValidator::FindRequiredFolder(const wstring& p_InitialPath, wstring p_RequiredFolderName)
- {
- wstring foundFolder = L"";
- wstring folderPath = p_InitialPath + L"\*";
- WIN32_FIND_DATAW folderInfo;
- HANDLE search_handle = FindFirstFileW(folderPath.c_str(), &folderInfo);
- if (search_handle != INVALID_HANDLE_VALUE)
- {
- vector<wstring> folders;
- do
- {
- if (folderInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- if ((!lstrcmpW(folderInfo.cFileName, L".")) || (!lstrcmpW(folderInfo.cFileName, L"..")))
- continue;
- }
- folderPath = p_InitialPath + L"\" + wstring(folderInfo.cFileName);
- if (folderInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- if (folderInfo.cFileName == p_RequiredFolderName)
- {
- foundFolder = folderInfo.cFileName;
- return foundFolder;
- }
- folders.push_back(folderPath);
- }
- } while (FindNextFileW(search_handle, &folderInfo));
- ::FindClose(search_handle);
- for (vector<wstring>::iterator iter = folders.begin(), end = folders.end(); iter != end; ++iter)
- FindRequiredFolder(*iter, p_RequiredFolderName);
- }
- return foundFolder;
- }
- wstring FoundFolder = FindRequiredFolder(L"C:", L"TextFiles_to_Test");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement