What is the best way to get all the files in a particular folder and compare the dates on those files? This is what I have so far and this will give me all the filenames and the date they were created:
Function ShowFolders(folderName)
Dim fs, f, f1, fc, s
s = ""
Set fs = CreateObject("Scripting.FileSystemObject"
Set f = fs.GetFolder(folderName)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name & " " & f1.DateCreated
s = s & (Chr(13) & Chr(10))
Next
ShowFolders = s
End Function
What I want to do with this information is to compare the dates on them and return the newest file. Thanks for the help.
Function ShowFolders(folderName)
Dim fs, f, f1, fc, s
s = ""
Set fs = CreateObject("Scripting.FileSystemObject"
Set f = fs.GetFolder(folderName)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name & " " & f1.DateCreated
s = s & (Chr(13) & Chr(10))
Next
ShowFolders = s
End Function
What I want to do with this information is to compare the dates on them and return the newest file. Thanks for the help.