<%Option Explicit%> would have prevented that.
hogwell wrote:
> Stuart,
>
> Thanks for this link, although I had already found this page myself
> earlier.
>
> I've now solved the problem, and this link turned out to be relevant
> after all!
>
> It was solved when I cut and pasted my code into this newsgroup for
> further help.
>
> Suddenly the 'fl' variable showed up as 'f1' - a typo!!!
>
> My original code was written in Dreamweaver and the font they use for
> code looks EXACTLY the same for the lower case letter L and the digit
> One.
>
> So, your comment about object names was also relevant - but note that
> this code is taken verbatim from the Microsoft Help file for
> FileSystemObject (except for the typo)!
>
> Thanks everyone for the help!
>
> Stuart Palmer wrote:
> > your code works for me, may be something to do with the path you have
> > stated. Try:
> >
> > Dim fso, f, fl, s, fs
> > Set fso = CreateObject("Scripting.FileSystemObject")
> > Set f = fso.GetFolder(Server.MapPath("/subfolder"))
> > Set fs = f.Files
> > For Each fl in fs
> > s = fl.Name
> > Response.Write(s)
> > Next
> > Set fso = Nothing
> >
> > might help fix the problem....but here it seems to work.
> >
> > You may have other code in that file that is effecting this trouble line, in
> > which case, something like
http://www.aspfaq.com/show.asp?id=2283 might be
> > somewhere to point you in (it might not have any direct relevance.
> >
> > I would also recommend you choose better object names, I don't think the
> > ones you have chosen help debug.
> >
> > Good luck.
> > Stu
> >
> > --
> >
> > <google@westernwares.com> wrote in message
> > news:1154060087.550490.294120@p79g2000cwp.googlegroups.com...
> > >I am trying to use the following ASP code to examine the file names in
> > > a folder:
> > >
> > > Dim fso, f, fl, s, fs
> > > Set fso = CreateObject("Scripting.FileSystemObject")
> > > Set f = fso.GetFolder("C:\Inetpub\wwwroot\MySite\subfolder")
> > > Set fs = f.Files
> > > For Each fl in fs
> > > s = fl.Name 'Object Required error occurs here!
> > > Response.Write(s)
> > > Next
> > > Set fso = Nothing
> > >
> > > The asp page returns the 'Object Required' error on the line, "s =
> > > fl.Name".
> > > Why?
> > >
> > > Can anyone shed any light on this?
> > >
> > > Thanks
> > >