Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use Item collection in WSH files object
Message
 
 
To
26/07/2002 11:55:09
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00683037
Message ID:
00683183
Views:
26
Unfortunately, you cannot reference items in the Files collection by numeric position. It accepts only a string key which is a file name. For example,
oFSO = CREATEOBJECT("Scripting.FileSystemObject")
oFolder = oFSO.GetFolder("C:\")
? SYS(2000, oFolder.Path + "\*.*")
lcFileName = SYS(2000, oFolder.Path + "\*.*")
? oFolder.Files(lcFileName).Name
>Using the Scripting.FileSystemObject
>
>I can get a reference to the files collection for a folder
>
>And reference it as follows
>
>FOR EACH file IN fold.files
> ? file.name
>next
>
>
>Since I often only want the first file found is there anyway I can avoid using "FOR EACH"
>
>I had expected to get a reference as follows
>
>myob= fold.Files.Item(1).name
>
>but this does not work. I get the error "Member Item does not evaluate to an object"
>
>What am I doing wrong:(
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform