Results 1 to 5 of 5

Thread: File Arrays w/o FSO

  1. #1

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032

    Question

    Is there a way to get all the files (full file name strings) in a given directory into an array without using the File System Object. I would do a for each loop on the array. Also, I do not need recursion, there's no need to get any directories in the given directory, just the files.

    Thanks,
    Josh

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ..search

    do a search on this site with some keywords...
    u'll find something

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Use Dir().

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  4. #4
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Talking

    Put a command button on a form and put this code in it's click event:
    Code:
    Private Sub Command1_Click()
        Dim arrFileHolder() As String
        Dim strFileName As String
        Dim intArrayIndex As Integer
        intArrayIndex = 0
        strFileName = Dir("C:\windows\desktop\")
        While strFileName <> ""
            ReDim Preserve arrFileHolder(intArrayIndex + 1)
            arrFileHolder(intArrayIndex) = strFileName
            strFileName = Dir
            intArrayIndex = intArrayIndex + 1
        Wend
        Dim times As Integer
        For times = 0 To intArrayIndex
            Debug.Print arrFileHolder(times)
        Next times
    End Sub
    Then, look in your Debug window...You'll see all of your files on your desktop...

    Hope that helps...

    Morgan
    Morgan
    teamtj@gmail.com - Home
    morgan.erickson@sprint.com - Work
    Using VB6 SP6 but trying to learn VB2005EE

  5. #5

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Thanks, that's what I needed. Combining that with a few API calls I can remove a form and scrrun.dll from my program.

    Josh

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