This code runs and works well, but I don't really want it to give me a messagebox with names. I want to get a count instead of the number of files there are instead. How can I rework this so that I get a count? Thank you.
int GetFileList(const wchar_t *searchkey, std::map<std::wstring,> &map)
{
WIN32_FIND_DATA fd;
HANDLE h = FindFirstFile(searchkey,&fd);
if(h == INVALID_HANDLE_VALUE)
{
return 0; }
while(1)
{
wchar_t buf[128];
FILETIME ft = fd.ftLastWriteTime;
SYSTEMTIME sysTime;
FileTimeToSystemTime(&ft, &sysTime);
wsprintf(buf, L"%d-%02d-%02d",sysTime.wYear, sysTime.wMonth, sysTime.wDay);
map[fd.cFileName] = buf;
if(FindNextFile(h, &fd) == FALSE)
break;
}
return map.size();
}
void main()
{
std::map<std::wstring,> map;
int count = GetFileList(L"C:\\Users\\DS\\Downloads\\*.zip", map)
&& GetFileList(L"C:\\Users\\DS\\Downloads\\*.txt", map);
for(std::map<std::wstring,>::const_iterator it = map.begin();
it != map.end(); ++it)
{
MessageBoxW(NULL,it->first.c_str(),L"File Name",MB_OK);
MessageBoxW(NULL,it->second.c_str(),L"File Date",MB_OK);
}
}