12-03-2004 01:01 AM
12-03-2004 06:49 PM
#include
#include "toolbox.h"
#include
int main()
{
int result;
int seconds;
int minutes;
int hours;
int year;
int day;
int month;
char maxName[500];
char fileName[500];
char *filePath = "C:\\Filepath";
char fullPath[500];
char searchPath[500];
time_t fileTime;
time_t maxTime;
static struct tm currentTime;
strcpy(searchPath, filePath);
strcat(searchPath, "\\*");
result = GetFirstFile (searchPath, 1, 1, 0, 0, 0, 0, maxName);
strcpy(fullPath, filePath);
strcat(fullPath, "\\");
strcat(fullPath, maxName);
GetFileDate (fullPath, &month, &day, &year);
GetFileTime (fullPath, &hours, &minutes, &seconds);
currentTime.tm_year = year-1900;
currentTime.tm_mon = month;
currentTime.tm_mday = day;
currentTime.tm_hour = hours;
currentTime.tm_min = minutes;
currentTime.tm_sec = seconds;
maxTime = mktime (¤tTime);
while(!result)
{
result = GetNextFile (fileName);
strcpy(fullPath, filePath);
strcat(fullPath, "\\");
strcat(fullPath, fileName);
GetFileDate (fullPath, &month, &day, &year);
GetFileTime (fullPath, &hours, &minutes, &seconds);
currentTime.tm_year = year-1900;
currentTime.tm_mon = month;
currentTime.tm_mday = day;
currentTime.tm_hour = hours;
currentTime.tm_min = minutes;
currentTime.tm_sec = seconds;
fileTime = mktime (¤tTime);
if(fileTime>maxTime)
{
maxTime=fileTime;
strcpy(maxName, fileName);
}
}
strcpy(fullPath, filePath);
strcat(fullPath, "\\");
strcat(fullPath, maxName);
printf("Newest File: %s\n", maxName);
printf("Full Path: %s\n", fullPath);
getchar();
return 0;
}
12-03-2004 06:50 PM
12-05-2004 03:19 PM