I want to get a file from the index... so say there was a folder, and I wanted to get the first file in that folder and put the name in a string. Is there a functi开发者_运维知识库on for that?
The FindFirstFile
API function returns what the file system considers to be the first file in the directory. If you want some later file, proceed to call FindNextFile
the appropriate number of times. In any case, call FindClose
afterward.
For NTFS, directories store their file names in sorted order. It might not be the order you want to display them in, though. For FAT, I think file names are stored in roughly the order they were created in. Deleting a file and then creating a new one might disrupt that order. Other local and network file systems might use still other orderings.
If you want files to be in a particular order, the better thing to do is to call FindFirstFile
and FindNextFile
until you've gotten all the files in a directory, and then sort them according to whatever criteria you really need instead of relying on the underlying file system.
精彩评论