Files/Folder Collection Access Syntax Question

M

Michael J Whitmore

I suppose I am asking this because I am hardheaded but here you go.
Is there another way to cycle through a list of Files/Folder
collection besides the use of Enumeration? I really want to use a for
loop because the other way looks so ugly (not to mention the
limitations of only being able to sequentially access the list), but
the following blows up when I try to access the individual folders in
the collection:

Blows up in the for loop:

FSO = new ActiveXObject("Scripting.FileSystemObject");
Folder = FSO.GetFolder(CurrentDirectory);
SubFolders = Folder.SubFolders;
alert(SubFolders.Count); // <==This works I get a number
for (Index=0; Index<SubFolders.Count; Index++) {
alert(Index);
FolderObject = SubFolders[Index].Item(); <== Blows up
}


I have tried many variations on how to get the individual FolderObject
out of the collection but none of them work. Any help would be
appreciated.

This works but gives me hives…

FSO = new ActiveXObject("Scripting.FileSystemObject");
Folder = FSO.GetFolder(CurrentDirectory);
CurrentDirectoryName = Folder.Name;
SubFolders = Folder.SubFolders;
SubFoldersEnum = new Enumerator(SubFolders);

for (; !SubFoldersEnum.atEnd(); SubFoldersEnum.moveNext()) {
FolderObject = SubFoldersEnum.item();
FolderObjectName = FolderObject.Name
alert("loadsystem.js - FolderObjectName : " +FolderObjectName)
}




Thanks!!!
Michael J Whitmore
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,118
Latest member
LatishaWhy
Top