filesystemobject

J

jim

I have an example that iterates through the fso folders collection etc for
the fso files collection. The problem is this:
the example uses an enumerator to cycle through the collection items and i
would like to use a for loop but I can't get the syntax correct.
for (var i=1;i<=length;i++) {
eFile=oFldr.files;
alert(eFile.item(1).type);
}
TIA
 
E

Evertjan.

jim wrote on 18 jun 2004 in comp.lang.javascript:
I have an example that iterates through the fso folders collection etc
for the fso files collection. The problem is this:
the example uses an enumerator to cycle through the collection items
and i would like to use a for loop but I can't get the syntax correct.
for (var i=1;i<=length;i++) {
eFile=oFldr.files;
alert(eFile.item(1).type);
}

perhaps the .item(1). should be .item(i). ?
and the i<=length be i<=oFldr.length ?

==============================================

M$ enumerates:

function ShowFolderFileList(folderspec) {
var fso, f, fc, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(folderspec);
fc = new Enumerator(f.files);

for (; !fc.atEnd(); fc.moveNext()) {
alert(fc.item().name + "\n" + fc.item().type);
}

}

not tested.

see:
<http://msdn.microsoft.com/library/en-us/script56/html/jsprofiles.asp>
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top