Sorting files from Datalist? IO.Directory ? SortedList?

Discussion in 'ASP .Net' started by jc, Jul 15, 2008.

  1. jc

    jc Guest

    Hello, I have this code that returns all my images to a datalist..
    works great , but I'd like to try soring them by filename or maybe
    file date... What's the best approach?

    Right now they come back in some random order.


    ' create a HashTable of values to bind to
    Dim pictures As New SortedList
    Dim file As System.IO.FileInfo
    Dim files As String()
    Dim filename As String = ""
    Dim i As Integer

    'files =
    System.IO.Directory.GetFiles(Server.MapPath(Request("path")), "*.*")
    files = System.IO.Directory.GetFiles("c:\ppp\")


    For i = 0 To files.Length - 1

    ' Create a New FileInfo object for this filename
    file = New System.IO.FileInfo(files(i))
    filename = file.Name.ToLower()

    If filename.EndsWith(".jpg") Then
    pictures("pictures/" & file.Name) = "thumb.aspx?
    src=pictures/" & file.Name
    End If

    Repeater1.DataSource = pictures

    Page.DataBind()
    Next


    Thanks for any help or information.
    jc, Jul 15, 2008
    #1
    1. Advertising

  2. jc

    sloan Guest

    Complete thread about it on July 2.

    http://groups.google.com/group/micr...read/thread/55b73ef5816731e6/299defd33a9848dc





    "jc" <> wrote in message
    news:...
    > Hello, I have this code that returns all my images to a datalist..
    > works great , but I'd like to try soring them by filename or maybe
    > file date... What's the best approach?
    >
    > Right now they come back in some random order.
    >
    >
    > ' create a HashTable of values to bind to
    > Dim pictures As New SortedList
    > Dim file As System.IO.FileInfo
    > Dim files As String()
    > Dim filename As String = ""
    > Dim i As Integer
    >
    > 'files =
    > System.IO.Directory.GetFiles(Server.MapPath(Request("path")), "*.*")
    > files = System.IO.Directory.GetFiles("c:\ppp\")
    >
    >
    > For i = 0 To files.Length - 1
    >
    > ' Create a New FileInfo object for this filename
    > file = New System.IO.FileInfo(files(i))
    > filename = file.Name.ToLower()
    >
    > If filename.EndsWith(".jpg") Then
    > pictures("pictures/" & file.Name) = "thumb.aspx?
    > src=pictures/" & file.Name
    > End If
    >
    > Repeater1.DataSource = pictures
    >
    > Page.DataBind()
    > Next
    >
    >
    > Thanks for any help or information.
    sloan, Jul 15, 2008
    #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. Nathan Sokalski

    Problem with SortedList

    Nathan Sokalski, May 30, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,867
    Karl Seguin
    May 30, 2005
  2. Thomas Weidenfeller

    Re: SortedList ?

    Thomas Weidenfeller, Jul 1, 2003, in forum: Java
    Replies:
    3
    Views:
    2,854
    Tim Tyler
    Jul 10, 2003
  3. Phil Hanna

    Re: SortedList ?

    Phil Hanna, Jul 2, 2003, in forum: Java
    Replies:
    0
    Views:
    811
    Phil Hanna
    Jul 2, 2003
  4. B-rad the Beat Nick

    SortedList: best practices with java 1.5

    B-rad the Beat Nick, Nov 4, 2005, in forum: Java
    Replies:
    5
    Views:
    113,011
    Roedy Green
    Nov 5, 2005
  5. sck10
    Replies:
    4
    Views:
    411
    sck10
    Sep 26, 2006
Loading...

Share This Page