Add Certain files in a Directory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jacobevans
    New Member
    • Aug 2007
    • 26

    Add Certain files in a Directory

    I want to be able to have someone click a command button, then have a directory form show, that part is complete. Now i need help adding all the files in this directory to a list with the extensions ".mp3, .wav, and .mid".
    (view code in discussion 'Directories and Listbox'
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Here's a simple code snippet that uses the FileSystemObjec t model to find all the files in C:\Temp and load their names into a listbox. It assumes that you have listbox named List1 on your form, and that you have added to your project a reference to Microsoft Scripting Runtime.

    [CODE=vb]Dim fso As New FileSystemObjec t
    Dim d As Folder
    Dim f As File
    Set d = fso.GetFolder(" C:\Temp")
    For Each f In d.Files
    List1.AddItem f.Name
    Next
    Set f = Nothing
    Set d = Nothing
    Set fso = Nothing[/CODE]

    Comment

    • jacobevans
      New Member
      • Aug 2007
      • 26

      #3
      Originally posted by Killer42
      Here's a simple code snippet that uses the FileSystemObjec t model to find all the files in C:\Temp and load their names into a listbox. It assumes that you have listbox named List1 on your form, and that you have added to your project a reference to Microsoft Scripting Runtime.

      [CODE=vb]Dim fso As New FileSystemObjec t
      Dim d As Folder
      Dim f As File
      Set d = fso.GetFolder(" C:\Temp")
      For Each f In d.Files
      List1.AddItem f.Name
      Next
      Set f = Nothing
      Set d = Nothing
      Set fso = Nothing[/CODE]
      i got it working, thanks much

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by jacobevans
        i got it working, thanks much
        Glad to help. :)

        Comment

        Working...