List Image by date in ASP

S

Sylvian Tam

Hi all,

I am using the File System Object to get a list of image through a specified
local path :

Dim fso, ffolder, ffile, fc, fproperity, strOut, strPic
Set fso = CreateObject("Scripting.FileSystemObject")
Set ffolder = fso.GetFolder(folderspec)
Set fc = ffolder.Files

For Each ffile in fc
intCount = intCount + 1
strPic = strPhotoPath & ffile.name
Set fproperity = fso.GetFile(strPic)

'show image one by one...

Next


I found that the image will be display by file name by default, is there any
way to show them by the created date or last accessed date?

Is there any way in doing this?

Thanks
Sylvian
 
M

Manohar Kamath [MVP]

As you loop through the files, create a recordset with file name and file
date. Then you can sort this recordset however you want.

' Create a custom recordset
Set filesRs = Server.CreateObject("ADODB.RecordSet")
filesRs.CursorLocation = 3 ' adUseClient
filesRs.Fields.Append "FileDate", adDate
filesRs.Fields.Append "FileName", adVarChar, 255
filesRs.Open

For Each ffile in fc
intCount = intCount + 1
strPic = strPhotoPath & ffile.name

...
filesRs.AddNew
filesRs("FileDate") = CDate(ffile.CreateDate) ' Check the property

filesRs("FileName") = CStr(ffile.Name) ' Check the property

Loop

' Sort the recordset on FileDate and proceed
filesRs.Sort = "FileDate ASC"

Hope that helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top