Load files show date modified ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ragazzo
    New Member
    • May 2007
    • 6

    Load files show date modified ?

    I am using this code to load files
    But i have problem when there is a large number of files, ( it shows nothing )
    is it posible to list only files where date modified is today`s date.
    And show in List "Modified Date" too.
    Sort by "Modified Date" -Descending
    Thank You
    Code used
    Code:
     
    Private Sub Form_Load()
    Dim LoadFiles   As String
    Dim strFill     As String
    LoadFiles = dir$("c:\test\*.txt", vbbHidden Or vbSystem)
    Do While LoadFiles > ""
    strFill = strFill & LoadFiles & ";"
    LoadFiles = dir$
    Loop
    lstFiles.RowSource = strFill
    End Sub
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32653

    #2
    Originally posted by ragazzo
    I am using this code to load files
    But i have problem when there is a large number of files, ( it shows nothing )
    I have no idea why this is the case for you. Can you be clearer as to when this happens?
    Originally posted by ragazzo
    is it posible to list only files where date modified is today`s date.
    I'm pretty sure not I'm afraid. The search string and the attributes are the only ways I could find to specify what you want returned.
    Originally posted by ragazzo
    Sort by "Modified Date" -Descending
    Another "No" again I'm afraid.

    You can load them into an array and sort them there of course, but as you only have the name at this stage it can only really be done alphabetically.

    Sorry I could be no more help and welcome to Bytes!

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by ragazzo
      I am using this code to load files
      But i have problem when there is a large number of files, ( it shows nothing )
      is it posible to list only files where date modified is today`s date.
      And show in List "Modified Date" too.
      Sort by "Modified Date" -Descending
      Thank You
      Code used
      Code:
       
      Private Sub Form_Load()
      Dim LoadFiles   As String
      Dim strFill     As String
      LoadFiles = dir$("c:\test\*.txt", vbbHidden Or vbSystem)
      Do While LoadFiles > ""
      strFill = strFill & LoadFiles & ";"
      LoadFiles = dir$
      Loop
      lstFiles.RowSource = strFill
      End Sub
      I cleaned the code up for you a little, this should work:
      Code:
       
      Dim strLoadFiles As String
      Dim strFill As String
      '
      'Good idea to specifically set the Row Source Type
      Me![lstFiles].RowSourceType = "Value List"
      '
      'strLoadFiles = Dir$("C:\Test\*.txt")       'Normal Attribute Files
      '
      'Why would a *.txt File have the Hidden or System Attribute?
      strLoadFiles = Dir$("C:\Test\*.txt", vbHidden Or vbSystem)
      '
      Do While strLoadFiles <> ""
        If CDate(Format$(FileDateTime("C:\Test\" & strLoadFiles), "mm/dd/yyyy")) = Date Then
          strFill = strFill & strLoadFiles & ";"
        End If
        strLoadFiles = Dir$
      Loop
      '
      'Remove Trailing Semi-Colon
      lstFiles.RowSource = Left$(strFill, Len(strFill) - 1)
      End Sub

      Comment

      Working...