Name
Files Collection Object
Creatable
No
Returned by
Folder.Files property
Library
Microsoft Scripting Runtime
Description
The Files collection object is one of the objects in the File System object model; for an overview of the model, including the library reference needed to access it, see the “File System Object Model” entry.
The Files collection object is a container for File objects that is returned by the Files property of any Folder object. All files contained in the folder are included in the Files collection object. You can obtain a reference to a Files collection object using a code fragment like the following:
Dim oFS, oFiles Set oFS = WScript.CreateObject("Scripting.FileSystemObject") Set oFiles = oFS.Drives("C:").RootFolder. _ SubFolders("Windows").Files
This code returns the Files collection for the Windows folder.
You can obtain a reference to an individual File object using the
Files collection object’s Item property; this takes the exact
filename, including the file extension, as an argument. To iterate
through the collection, you can use the For
Each...Next
statement. For details, see the entry
for the File Object.
The Files collection object is read-only. Consequently, it supports only the following two properties:
Properties
- Count
Data Subtype: Long
The number of File objects in the collection.
- Item
Data Subtype: File object
Takes the filename (including the file extension) as a parameter and returns the File object representing the file with that name. Individual File objects ...
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.