How to address one item in a collection object

  • Thread starter Thread starter Guojun Zhu
  • Start date Start date
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.
 
Back
Top