Results 1 to 3 of 3

Thread: get list of files in the same directory

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    65

    Post

    how do you get your program to get a list of files with a certain extension that are located in the same directory as your app into a listbox?

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    use a filelistbox
    and ...

    File1.Pattern = "*.exe" ' or whatever
    File1.Path = App.Path
    File1.Refresh

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    You can use the FileListBox. Just set the pattern property to whatever files you want to show.

    If you want to use an ordinary ListBox you can use code simular to this:

    Private Sub FillListBox(sPath$, sPattern$, lstBox As ListBox)
    Dim sFile$
    sPath = spath & IIf(Right$(sPath, 1)<>"\", "\", "")
    sFile = Dir(sPath & sPattern)
    Do While Len(sFile) > 0
    lstBox.AddItem sFile
    sFile = Dir
    Loop
    End Sub

    You call the sub above in the following manner:
    FillListBox "C:\", "*.exe", List1
    This will fill a listbox named List1 whit all files in the C:\ directory that has the .Exe extension.

    Good luck!

    ------------------
    Joacim Andersson
    [email protected]
    [email protected]
    www.YellowBlazer.com



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