/    Sign up×
Community /Pin to ProfileBookmark

for…in not working

I’m trying to use a for…in loop to access a property of the ASP Files object. When the for loop gets executed, it doesn’t enter the loop, instead it immediately falls through. I know that the folder I’m referencing exists and that it contains 11 files. Would someone mind look at my for…in loop and telling me what is wrong?

[code=php]
fs=Server.CreateObject(“Scripting.FileSystemObject”);
if (fs.FolderExists(Server.MapPath(“/IMDb Movie HTML”))==true)
Response.Write(“<p>Folder exists</p><br />”);
else
Response.Write(“<p>Folder Not Found</p><br />”);
fo=fs.GetFolder(Server.MapPath(“/IMDb Movie HTML”));
Response.Write(“<p>Before for loop: filename=”+fo.Files.Name+”</p><br />”);
for (file in fo.Files)
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterAug 08.2005 — Maybe this will point you in the right direction:
<i>
</i> oFSO = new ActiveXObject("Scripting.FileSystemObject");
MyRoot = oFSO.GetFolder(Server.MapPath("/IMDb Movie HTML"))

ff = new Enumerator(MyRoot.subfolders);
s = "";
for (; !ff.atEnd(); ff.moveNext())
{
var x=String(ff.item()).split("\");
var fname= (x.length&lt;1)?"":x[x.length-1];
s += fname;
s += "&lt;br /&gt;n";
}
Response.Write(s);

My server doesn't support JavaScript so I won't be able to test it.
Copy linkTweet thisAlerts:
@JazzcatCBauthorAug 09.2005 — Thank you for the help. That does indeed work.
×

Success!

Help @JazzcatCB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...