I am working on a script that will delete files from a folder that was modified over a week ago and i am having trouble with getting the last modified date into a string.
So I am trying to write the last modified date of a file to a string vector.
The bolded line is the error line, it says
||=== Build: Debug in WeekaDelete (compiler: GNU GCC Compiler) ===| \WeekaDelete\main.cpp||In function 'int main(int, char**)':| \WeekaDelete\main.cpp|21|error: cannot bind 'std::ostream {aka std::basic_ostream}' lvalue to 'std::basic_ostream&&'| codeblocks\mingw\lib\gcc\mingw32\4.8.1\include\c++\ostream|602|error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits; _Tp = _FILETIME]'| ||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
#include <windows.h>
#include <vector>
#include <ctime>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
WIN32_FIND_DATA search_data;
memset(&search_data, 0, sizeof(WIN32_FIND_DATA));
HANDLE handle = FindFirstFile("C:\\Users\\Meikle-John\\Desktop\\CoastWideCivil\\C++\\Scans\\*", &search_data);
int ifilecount = -2;
vector<string> vsname, vsdate;
string tempn, tempd;
while(handle != INVALID_HANDLE_VALUE)
{
tempn = search_data.cFileName;
**tempd = search_data.ftLastAccessTime;**
cout << tempd << endl;
cout << tempn << " : " << tempd << endl;
cout << ifilecount++ << endl;
if(ifilecount > -1)
{
vsname.push_back(tempn);
vsdate.push_back(tempd);
}
if(FindNextFile(handle, &search_data) == FALSE)
{
break;
}
}
//Close the handle after use or memory/resource leak
FindClose(handle);
cout << "There are:" << ifilecount << " Files in this directory" << endl;
return 0;
}