This example returns the most recent file in a directory. The VI searches for all the first-level files in a given directory, and compares the "last modified date" value of each file. The VI displays the full path of the file with the most recent date. The VI returns a list of all the files found in an array. This VI does not search for files inside the sub-directories.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.