I'm using the following code to perform a recursive loop in order to get a total count of all files contained within a parent folder and it's sub folders.
I know there are about 400000 files in total however this code takes forever to perform the task. Going to the folder properties returns this information in a fraction of the time.
Is there a quicker way?
Thanks
Nick
Code:
Sub CountFiles(OfFolder As Scripting.Folder)
Dim SubFolder As Scripting.Folder
FileCount = FileCount + OfFolder.Files.Count
For Each SubFolder In OfFolder.SubFolders
CountFiles OfFolder:=SubFolder
Next SubFolder
End Sub
I know there are about 400000 files in total however this code takes forever to perform the task. Going to the folder properties returns this information in a fraction of the time.
Is there a quicker way?
Thanks
Nick