Hi, I'm using the following code to capture all files in a directory -
but when I pass the "path" var such as "C:\SomeDir" ffd.cFileName is just simply "SomeDir" and is seen as a valid folder and no more files are processed.. I'm trying to get the contents in that folder. Where am I going wrong? I'm following this example here -
http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
Code:bool ListFiles(TCHAR* path) { HANDLE hFind = INVALID_HANDLE_VALUE; WIN32_FIND_DATA ffd; TCHAR * spec = new TCHAR[_MAX_PATH]; static std::stack<TCHAR*> directories; static std::vector<TCHAR *> files; files.clear(); LPTSTR szANSIString[MAX_PATH] = {0}; hFind = FindFirstFile(path, &ffd); if (hFind == INVALID_HANDLE_VALUE) { return false; } do { if (_tcscmp(ffd.cFileName, _T(".")) != 0 && _tcscmp(ffd.cFileName, _T("..")) != 0) { if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { directories.push(ffd.cFileName); } else { files.push_back(ffd.cFileName); } } } while (FindNextFile(hFind, &ffd) != 0); if (GetLastError() != ERROR_NO_MORE_FILES) { FindClose(hFind); return false; } FindClose(hFind); hFind = INVALID_HANDLE_VALUE; return true; }


Reply With Quote
Bookmarks