Property: Count for Files
- Updated2024-09-12
- 1 minute(s) read
FileSystemObject and Dictionary > Properties > Property: Count for Files
Property: Count for Files
Returns the number of files in a folder.
Object.Count
| Object | Files Object with this property |
| Object.Count | LongInteger with read access |
The following example returns the number of files in a folder:
Function CountFiles(sFolderSpec) Dim fso, oMyDrive, oMyFolder, oMyFiles Set fso = CreateObject("Scripting.FileSystemObject") Set oMyFolder = fso.GetFolder(sFolderSpec) Set oMyFiles = oMyFolder.Files CountFiles = "Number of Files: " & oMyFiles.Count End Function