Hi,
I trying to get the LAST modified text file in a folder, but unsure how to do it.
I am using the following code:-
http://www.adrianxw.dk/SoftwareSite/FindFirstFile/findfirstfile3.html
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
SYSTEMTIME SysTime;
HANDLE hFind;
WIN32_FIND_DATA FindData;
cout << "A very basic FindFirst/Next demo.\n" << endl;
// Find the first file
hFind = FindFirstFile ( "//server4/data/Reports/MANAGER/*.txt", &FindData );
cout << FindData.cFileName << " ";
FileTimeToSystemTime ( &FindData.ftCreationTime, &SysTime );
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wDay << "/";
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wMonth << "/";
cout << SysTime.wYear << " ";
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wHour << ":";
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wMinute << ":";
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wSecond;
cout << endl;
// Look for more
while ( FindNextFile ( hFind, &FindData ) )
{
cout << FindData.cFileName << " ";
FileTimeToSystemTime ( &FindData.ftCreationTime, &SysTime );
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wDay << "/";
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wMonth << "/";
cout << SysTime.wYear << " ";
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wHour << ":";
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wMinute << ":";
cout.width ( 2 );
cout.fill ( '0' );
cout << SysTime.wSecond;
cout << endl;
}
FindClose ( hFind );
getchar();
return 0;
}
Will I have to create my own date and time class to decide which text file is the most recent or is there an easier way?