Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FSO Files Collection Size Limitation?!?

Status
Not open for further replies.

Schof

Programmer
Nov 18, 2002
103
0
0
CA
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
    ...
 
Looks like it is a display issue in the watch window. The code below will demonstrate that this limitation actually does not exist in the collection itself:

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
            X = X + 1
            Debug.Print X & vbTab & objFile        
         Next objFile
    End If
End Function

Props to DCrake for the counter suggestion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top