List Image by date in ASP

Discussion in 'ASP General' started by Sylvian Tam, Oct 11, 2003.

  1. Sylvian Tam

    Sylvian Tam Guest

    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
     
    Sylvian Tam, Oct 11, 2003
    #1
    1. Advertising

  2. 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.

    --
    Manohar Kamath
    Editor, .netBooks
    www.dotnetbooks.com


    "Sylvian Tam" <> wrote in message
    news:...
    > 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
    >
    >
     
    Manohar Kamath [MVP], Oct 11, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    646
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,365
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    566
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    755
    Richard Heathfield
    Nov 8, 2003
  5. Matt
    Replies:
    11
    Views:
    426
    Aaron Bertrand [MVP]
    Nov 8, 2003
Loading...

Share This Page