Results 1 to 2 of 2

Thread: Find the latest date of folder

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Find the latest date of folder

    Hi all,

    How to find the latest sub-folder in a folder?

    Example:

    Let's say I have a folder C:\Temp. I have 100 folders on it. I want to find the latest created/modified sub-folder of C:\Temp\

    Please help

    Thanks.
    Kanna

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Find the latest date of folder

    Fils System Object could be the simplest way but not the fastest (which is the API way):
    Code:
    Private Sub Command1_Click()
    '============================
    Dim fso As Object
    Dim fldr As Object
    Dim sfldr As Object
    Dim sDate As Date
    Dim sName As String
    
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set fldr = fso.GetFolder("c:\")
        
        Screen.MousePointer = vbHourglass
        
        For Each sfldr In fldr.SubFolders
            If sDate < CDate(sfldr.DateLastModified) Then
                sDate = CDate(sfldr.DateLastModified)
                sName = sfldr.Name
            End If
        Next sfldr
        
        Screen.MousePointer = vbDefault
        
        MsgBox "Most recently modifed folder: " & sName & vbNewLine & _
               "Date modified: " & sDate
    
    End Sub

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