11.6 FilesCollection

A collection of file objects with in a folder.

For Web-based scripts, the number of entries depends on the user rights.

11.6.1 Count property

Returns the number of items in a collection object.

Syntax

 object.Count
 

Type

Long.

Attributes

Read-only.

Example

See sample in Example.

11.6.2 HasMoreElements method

Returns TRUE if there is any file in Section 11.6, FilesCollection.

Syntax

 object.HasMoreElements
 

Parameters

None.

Return Values

Boolean.

Example

See sample in Example.

11.6.3 Next method

Returns the next file object from the Section 11.6, FilesCollection. If there are no more files in the collection it returns NULL.

Syntax

 object.Next
 

Parameters

None.

Return Values

Folder.

Example

See sample in Example.

11.6.4 Reset method

Resets the collection of the files in the Section 11.6, FilesCollection object.

Syntax

 object.Reset
 

Parameters

None.

Return Values

Void.

Example

This example resets the collection.

 <% Set FSO = CreateObject("Scripting.FileSystemObject")
 Set Folder = FSO.GetFolder ("Sys:\nsn\user")
 Set Files = Folder.Files
 
 ’Returns the number of files in the folder collection 
 Response.Write Files.Count %>
 
 <%’Resets the collection
 Files.Reset()
 
 ’Checks for files in the collection
 Do While Files.HasMoreElements()
    For each file in Files
      Response.Write File.Name
    Next
   ’Sets the pointer to the next file in the collection
    Files.Next()
 Loop %>
 

11.6.5 Item method

Returns an item based on the specified filename.

Syntax

 object.Item(
    FileName As String)
 

Parameters

FileName
Name of the file that has to be returned.

Return Values

Section 11.4, File.

Example

This example returns the file object.

 <% Set FSO = CreateObject("Scripting.FileSystemObject")
  Set Folder = FSO.GetFolder ("Sys:\nsn\user")
  Set Files = Folder.Files
  Set File = Files.Item ("date.bas")%>