O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Files Collection Object

Createable

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 = 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 Type: Long

The number of File objects in the collection.

Item

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required