【发布时间】:2018-08-18 12:56:24
【问题描述】:
我需要目录中所有文件的创建日期,它适用于所有文件,但不适用于文件夹。
int antiguedad(char * nombre){
ZeroMemory(&fileinfo, sizeof(BY_HANDLE_FILE_INFORMATION));
// obtain a handle to the file, in this case the file
// must be in the same directory as your application
HANDLE myfile = NULL;
//char * nombre = "nuevooo.txt";
myfile = CreateFileA(nombre,0x00,0x00,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
// if we managed to obtain the desired handle
if(myfile!=INVALID_HANDLE_VALUE)
{
//try to fill the structure with info regarding the file
if(GetFileInformationByHandle(myfile, &fileinfo))
{
SYSTEMTIME systemTime;
FileTimeToSystemTime(&fileinfo.ftCreationTime, &systemTime);
printf("El archivo tiene %i dias \n", diferenciaEndias(systemTime.wDay,systemTime.wMonth, systemTime.wYear));
}
CloseHandle(myfile);
}
else {
printf("IT A FOLDER \n");
}
return 0;
}
我认为文件夹需要特定代码,但我什么也没找到
【问题讨论】:
标签: c windows time directory creation