FSO Files Collection Size Limitation?!?

Schof

Registered User.
Local time
Today, 21:45
Joined
Nov 15, 2002
Messages
44
I seemed to have run up against a 256 file limitation in the FileSystemObject Files collection?!? Can anyone confirm this or point to a workaround that does not entail piping the output to a file and iterating through that?

Code:
    Dim objFSO As New FileSystemObject
    Dim objFolder As Folder
    Dim objFiles As Files
    Dim objFile As File
    dim strFolder As String

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    strFolder = "C:\Windows\System32"

    If objFSO.FolderExists(strFolder) Then
        Set objFolder = objFSO.getfolder(strFolder)
        For Each objFile In objFolder.Files
        Next objFile
    End If
    ...


Thank you in advance.
 

Attachments

  • fso.jpg
    fso.jpg
    49.9 KB · Views: 197
Code:
Function FSO()
   Dim objFSO As New FileSystemObject
    Dim objFolder As Folder
    Dim objFiles As Files
    Dim objFile As File
    Dim strFolder As String

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    strFolder = "C:\Windows\System32"

    If objFSO.FolderExists(strFolder) Then
        Set objFolder = objFSO.getfolder(strFolder)
        For Each objFile In objFolder.Files
[B]            X = X + 1
            Debug.Print X & vbTab & objFile[/B]        
         Next objFile
    End If
End Function

I just ran this code from the immediate window and it listed 2228 files

/.......
2227 C:\WINDOWS\system32\zonedoff.reg
2228 C:\WINDOWS\system32\zonedon.reg

David
 
Thanks for the suggestion. It looks like it is merely a display issue in the watch window that it only shows 256 items.
 
That's correct.
Writing to a text file can be your friend in such occasions (or of course a handy little bit of the immediate database integration working in Access offers such as a local "dump" table ;-)

Either isn't a great idea if you're timing the procedure though.
 

Users who are viewing this thread

Back
Top Bottom