Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is it possible to step backwards through filesystemobject? 1

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
AU
Hey there everyone,

I have created a filesystemobject that displays thumbnails of all the images in a directory. So far so good

If someone clicks on the thumb and displays the full size image, I want to give it some gallery-type behaviours with a next image and previous image link.

Once I have the list of images in the object, how can I show the current image and at the same time get the name of the next and previous?

I am more used to PHP in which, if it was an array, I would move the pointer forward or backward, but I can't see how to do this or even if it can be done in ASP.

Thanks muchly in advance.

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
I was going to say GetFiles but alas FSO doesn't seem to have this method.

My suggestion without trying much is to step the object and build an array of the file (image) paths. This way you have control and state over navigating however you seem needed through the images


[sub]____________ signature below ______________
I am Tedward Keyboardhands!!!
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
Thanks for the suggestion. That was what I was considering, but I thought there may be a built in method.

I'll see what comes up from others.

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
hmm...

FSO.Files is what you're looking for I think

Set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFolder("c:\")
Set fc = f.Files



[sub]____________ signature below ______________
I am Tedward Keyboardhands!!!
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
Transfer the file names into a dictionary is one way

Code:
<%
dim objFSO ,objFolder ,x , iCount
set objFSO=Server.CreateObject("Scripting.FileSystemObject")
set objFolder=objFSO.GetFolder(server.mappath("/unused"))
set dict = server.createobject("scripting.dictionary")
iCount = 0
for each x in objFolder.files
  dict.add icount, x.name
  iCount = iCount + 1
next

' example 
iCount = 5
response.write dict.item(iCount-1) & "<br />"
response.write dict.item(iCount) & "<br />"
response.write dict.item(iCount+1) & "<br />"

set dict=nothing
set objFolder=nothing
set objFSO=nothing
%>


Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Excellent Chris,

Exactly what I was after, and I learned something. Have never used scripting.dictionary before.

It looks like that is an ad-hoc object that you can write what you like to. Am I close?

Steve Davis

NOTE: This sig does not include any reference to voting, stars, or marking posts as helpful as doing so is cause for membership termination.
 
It was my graphics designer idea of putting a couple of code snippets in the header image.

You can tell why we don't let him do any coding 'cos the syntax isn't right. [ponder]



Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top