PowerBasic Museum 2020-A

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Windows Script Runtime => Source Code => Scripting => FileSystemObject => Topic started by: José Roca on July 14, 2008, 12:22:06 AM

Title: IFolderCollection.NewEnum_ Property
Post by: José Roca on July 14, 2008, 12:22:06 AM


The following example illustrates the use of the NewEnum_ property to parse a collection of folders.


#INCLUDE "windows.inc"
#INCLUDE "scrrun.inc"

DIM fso AS IFileSystem
DIM pFolder AS IFolder
DIM pSubFolders AS IFolderCollection
DIM pEnum AS IEnumVARIANT
DIM vItem AS VARIANT
DIM celtFetched AS LONG

' Create an instance of the FileSystemObject
fso = NEWCOM "Scripting.FileSystemObject"
' Get a reference to the IFolder interface
pFolder = fso.GetFolder(UCODE$("C:\"))
' Get a reference to the IFileCollection interface
pSubFolders = pFolder.SubFolders
' Enumerate the collectiion
pEnum = pSubFolders.NewEnum_
DO
   pEnum.Next 1, vItem, celtFetched
   IF celtFetched = 0 THEN EXIT DO
   pSubFolder = vItem
   MSGBOX ACODE$(pSubFolder.Name)
LOOP