Click to See Complete Forum and Search --> : What's the best way to read directories?


jammer20002
11-06-2003, 07:53 PM
I need to create a dynamic page that reads the names of images in a directory and then with that constructs a page to show the images as thumbnails ona HTML page.

What's the best way to read in a directory?

I've been trying to copy someone elses code, which is the following:

set fso = server.CreateObject("scripting.filesystemobject")
set fol = fso.getfolder(server.MapPath(images_directory_name))

for each fil in fol.files

do some actions.

next

set fol = nothing
set fso = nothing

The problem is that the above code takes a long time to execute! Is there a better way?

Surely, the best way would be to get a directory listing, and then strip out the image names? Instead of doing actions while the fol and fso objects are open?

I'm really new to ASP (and VBScript) so... I don't have much clue what the best solution is.

ANY help wouldbe appreciated.

Thanks.


Jam

Nicodemas
11-10-2003, 12:23 PM
What kind of actions do you want performed inside the loop? It really shouldn't take *that* long.

jammer20002
11-10-2003, 02:07 PM
Thanks for the reply.

What I want to do:

If there are 50 images, then i want to read in the names of those 50 images and contruct one page with 10 images on, say. This page is to have a 'next' button. When the next button is pressed, the next page is displayed which show the next 10 images. etc.

What would you say is the best way of doing the above?
I thought it would be straight forward and simple to do.
I've programmed in Perl in the past and I know that in Perl, doing the above would take a micro second to do!

For some reason... the ASP I have takes tooo long. :(

Any suggestions?

Thanks.