Results 1 to 2 of 2

Thread: Finding most recent file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 1999
    Location
    u.s.a
    Posts
    127
    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.

  2. #2
    Guest
    Use a FileListBox to list all files. And use the FileDateTime function to determine when a file was last modified.
    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
    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:
    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
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width