05-21-2007 04:45 AM
05-21-2007 05:21 AM
Markus, how do you define the "last" file in the folder? The last recorded file or the last indexed file (supposing files are named for example as "ABCxxx.DAT" with xxx=progressive creation index)?
In either way, you can retrieve a list of files in at least two ways:
1. executing a loop with GetNextFile after the initial GetFirstFile. The problem is I don't know exactly which is the built-in order for these functions (creation date / access date, location on disk, name, other orders?) so you may need to scan all filenames listed and decide which one to consider
2. creating a list of filenames using DOS DIR command and scanning it. If the sorting algorithm is already included in the command, you can only retrieve the first element in the list and use it. As an example, to sort all *.DAT files in a folder, sorted by creation date from the most recend you can execute this command: system ("dir /b c:\myFolder\*.dat /o:-d /t:c > output.txt"); reading next the first line of "output.txt" file that contains the filename only
There are several other sorting criteria built in DIR command: you can look at command help typing "help dir" at a command prompt
05-21-2007 05:49 AM
@Roberto Bozzolo wrote:
1. executing a loop with GetNextFile after the initial GetFirstFile. The problem is I don't know exactly which is the built-in order for these functions (creation date / access date, location on disk, name, other orders?) so you may need to scan all filenames listed and decide which one to consider
For each file that is found using GetFirstFile and GetNextFile, call the GetFileDate and GetFileTime functions. This way you can check which is the most recently created file.