How to address one item in a collection object

G

Guojun Zhu

I am using VBscript in ASP. I am trying to address one file in a folder
object. Below is the relevant code


Set MyDirectory=Server.CreateObject("Scripting.FileSystemObject")
' MyFolders is contents of folder containing photos.asp
Set MyFolders=MyDirectory.GetFolder(Server.MapPath("./"))

Then I try to access the first file in the "MyFolder"
I tried
1. Set filefound=MyFiles.files.item(1)
2. Set filefound=MyFiles.files(1)
3. Set filefound=MyFiles.files[1]
Neither work. There is compilation error.
But

For each filefound in MyFiles.files

works
"myfiles.files" is a collection object of file objects, isn't it?

Any experts help me please. Thanks.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top