Results 1 to 4 of 4

Thread: How to get a list of files

  1. #1
    Guest

    Angry

    I've created a folder filled with HTML files from my Temporary Internet Files folder. What I want to do is open the first (or most recent) file to search.

    As I won't know the name of the file is there anyway of say, populating a list box with filenames, or something, so I can just work my way down the list scanning each file?

    Thanks
    Mafro

  2. #2
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217
    Just use a FileListBox (if you're using VB6). Otherwise, use Dir and fill a regular ListBox with all the filenames.

  3. #3
    Guest
    If you do not want to add list boxes to your form
    use the file system object.
    [
    Sub ShowFileList(folderspec)
    Dim fs, f, f1, fc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(strFolderNameVariable)
    Set fc = f.Files
    For Each f1 in fc
    s = s & f1.name
    s = s & vbCrLf
    Next
    MsgBox s
    End Sub

    ]

  4. #4
    Guest
    Code:
    Sub ShowFileList(folderspec)
        Dim fs, f, f1, fc, s
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set f = fs.GetFolder(folderspec)
        Set fc = f.Files
        For Each f1 In fc
            s = s & f1.Name
            s = s & vbCrLf
        Next
        MsgBox s
    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