Files Collection Object
Microsoft Scripting Runtime
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 = 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
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.
Data Type: Long
The number of File objects in the collection.
Data Type: 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 can’t be accessed ...