Я работаю над скриптом, который удалит файлы из папки, которая была изменена в течение недели назад, и у меня возникли проблемы с получением последней измененной даты в строку.Дата последнего изменения файла в строке C++
Итак, я пытаюсь записать последнюю измененную дату файла в вектор строки.
жирным шрифтом линия линия ошибки, это говорит
||=== 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;
}
после того, как был вставлен фрагмент кода, код не будет компилироваться '_countof' не объявлен Разве дело не от ?? –
@ Meikle-John Вместо этого вы можете использовать 'sizeof (tchDate)/sizeof (tchDate [0])'. –