Results 1 to 1 of 1

Thread: More efficient way to do a file count??

  1. #1
    Join Date
    Nov 2002

    Question More efficient way to do a file count??

    I use this code to get a file count recursively on a folder is the a more efficient way of doing this??

    Dim cnt

    Sub Recurse(Path)

    Dim fso, Root, WindowsFolder, Files, Folders, File, i, FoldersArray(10000)

    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    Set Root = fso.getfolder(Path)
    Set Files = Root.Files
    Set Folders = Root.SubFolders
    Server.ScriptTimeout = 10000

    For Each Folder In Folders

    Dim objFSO, objFolder

    Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
    Set objFolder=objFSO.GetFolder(Folder.Path)
    cnt = cnt + objFolder.files.Count
    Set objFolder = Nothing
    Set objFSO = Nothing
    FoldersArray(i) = Folder.Path
    i = i + 1

    For i = 0 To UBound(FoldersArray)
    if FoldersArray(i) <> "" Then
    Recurse FoldersArray(i)
    Exit For
    End if

    End Sub

    Recurse "D:\Folder to Count\"


    Last edited by Dr.5150; 11-22-2002 at 01:36 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center