Is there a way to find the most recent file modified in a folder.
Is there an API or VB function or will I have to go through all files one by one and check their date of modification?
Thanks.
Dan.
Printable View
Is there a way to find the most recent file modified in a folder.
Is there an API or VB function or will I have to go through all files one by one and check their date of modification?
Thanks.
Dan.
Use a FileListBox to list all files. And use the FileDateTime function to determine when a file was last modified.
I am not sure about find the most recent file modified, but I have an idea. At least to find one that was created on the same date, not sure about most recent time though.Code:'Needed: Listbox, FileListBox (DirListBox), CommandButton
Private Sub Command1_Click()
For i = 0 To File1.ListCount - 1
lasmod = FileDateTime(File1.List(i))
List1.AddItem File1.List(i) & " - " & lasmod
Next i
End Sub
Using the Instr function should help. I'm sorry I can't come up with a way to find out the most recent file modified. But if I dream up something else, I'll let you know.Code:On Error Resume Next
List1.ListIndex = -1
For i = 0 To List1.ListCount - 1
List1.ListIndex = List1.ListIndex + 1
If InStr(List1.List(i), Date) Then MsgBox "Found!": Exit Sub
Next i