0
我试图从文件中读取创建日期,将其存储在一个字符串中,然后将其输出到格式化的CSV文件。现在,我浑然一语地从各种各样的源头嘲讽代码,希望它能做我想做的事情,但没有很好的补充,它没有(1601年有个约会,显然至少有一个转换不起作用)。获取文件创建日期并将其放入字符串
我目前正在使用;
char sourceAfilename[255]; // The name of the source file I want to
// get the creation date of
FILE sAptr; // Pointer to the source file
FILE o1ptr; // Pointer to the output file
std::string sAdateString; // date field - String
const char* sAdateText; // date field - char array
FILETIME sAfileTime; // filetime version of the date
SYSTEMTIME sAsystemTime; // systemtime version of the date
std::stringstream sAstringStream; // Temp stringstream
HANDLE sAhandle // Handle of the File
// Open the files
// read and write stuff from/to the files
// now get the date of the source file
fileHandle = CreateFile(LPWSTR(sourceAfilename), GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
GetFileTime(sAhandle, &sAfileTime, NULL, NULL);
CloseHandle(sAhandle);
FileTimeToSystemTime(&sAfileTime, sAsystemTime);
sAstringStream << sAsystemTime.wDay << '/' << sAsystemTime.wMonth << '/' <<
sAsystemTime.wYear;
sAdatetext = sAdatestring.c_str();
// Now output the text version of the date to the output file
fputs(" * Creation date is - ", o1ptr);
fputs(sAdatetext, o1ptr);
fputs(" * \n", o1ptr);
如果有人能指出我要去哪里错了,或者给我一个简单版本的“获取文件的日期,并将其存储在字符数组”,的老年大加赞赏。
由于 理查德
sAdatetext = sAdatestring.c_str(); // sAdatestring获取数据在哪里? – Jagannath