Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need Code to Find Oldest File in a given directory...
Message
De
05/07/2000 14:50:24
 
 
À
05/07/2000 12:30:59
Information générale
Forum:
Visual C++
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00388297
Message ID:
00388464
Vues:
14
>I don't think there is a API/library routine that enables you to say "retreive oldest file or files by date". What you could do is use the _findfirst and _findnext routines to work through the directorys and files comparing the time_create, time_access, time_write members of the _finddata_t (whatever is appropriate to solve your problem).
>

Why not just do an ADIR(), and then either pull the array into a cursor and use a SQL statement to pull the desired record?

>I compiled the following code under Visual C++ 6.0 SP4, create a new WIN32 console application and turn off precompiled headers.
>
>MSDN includes a LOT of information on this subject if you need to look up the structures, another good tip is to turn on the Browse Information under:-
>
>Project->Project Settings->Browse Info->Build browse info file
>
>This will allow you to right click on the structures and functions and jump to their definitions in the header/source files.
>
>
>#include
>#include
>#include
>
>void main( void )
>{
> struct _finddata_t find_file;
> long hFile;
>
> if( (hFile = _findfirst( "*.*", &find_file )) == -1L )
> printf( "No files in current directory!\n" );
> else
> {
> printf( "Listing of all files\n\n" );
> printf( "\nRDO HID SYS ARC FILE DATE %25c SIZE\n", ' ' );
> printf( "--- --- --- --- ---- ---- %25c ----\n", ' ' );
> printf( ( c_file.attrib & _A_RDONLY ) ? " Y " : " N " );
> printf( ( c_file.attrib & _A_SYSTEM ) ? " Y " : " N " );
> printf( ( c_file.attrib & _A_HIDDEN ) ? " Y " : " N " );
> printf( ( c_file.attrib & _A_ARCH ) ? " Y " : " N " );
> printf( " %-12s %.24s %9ld\n",
> c_file.name, ctime( &( c_file.time_write ) ), c_file.size );
>
> while( _findnext( hFile, &c_file ) == 0 )
> {
> printf( ( c_file.attrib & _A_RDONLY ) ? " Y " : " N " );
> printf( ( c_file.attrib & _A_SYSTEM ) ? " Y " : " N " );
> printf( ( c_file.attrib & _A_HIDDEN ) ? " Y " : " N " );
> printf( ( c_file.attrib & _A_ARCH ) ? " Y " : " N " );
> printf( " %-12s %.24s %9ld\n",
> c_file.name, ctime( &( c_file.time_write ) ), c_file.size );
> }
>
> _findclose( hFile );
> }
>}
>
>
>HTH
>Neil
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform