Results 1 to 3 of 3

Thread: Populating a LISTVIEW with directory contents...

  1. #1

    Thread Starter
    Lively Member bgalm's Avatar
    Join Date
    Jan 1999
    Posts
    65

    Question

    Hello,
    The following routine populates a LISTVIEW control with a list of files that are contained in a text file. I would like to modify this so that the .EXE and .BAT files that are in a specific directory are loaded, for example, app.path
    Is there any way to do this without doing a DIR *.EXE > FILES.LST, then loading the file, the deleting the file ?

    Open App.Path & "\FILES.LST" For Input As #1
    Do While Not EOF(1)
    Line Input #1, STemp
    Set liEntry = ListView1.ListItems.Add(, , STemp, 0, 0)
    Loop
    Close #1

    Thanks,

  2. #2
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372
    I added a command button and a listbox to the form. I'm sure you can modify this to your needs.


    Private Sub Command1_Click()
    Dim FileDir As String

    FileDir = Dir("C:\Windows\")
    While FileDir <> ""
    DoEvents
    If UCase(Right(FileDir, 3)) = "BAT" Or _
    UCase(Right(FileDir, 3)) = "EXE" _
    Then
    List1.AddItem FileDir
    End If
    FileDir = Dir
    Wend
    End Sub


  3. #3

    Thread Starter
    Lively Member bgalm's Avatar
    Join Date
    Jan 1999
    Posts
    65

    Thumbs up Worked great. Thanks for your help...

    Thanks again,

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