Sorting files from Datalist? IO.Directory ? SortedList?

J

jc

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.
 

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

Top