J
jc
I have this code that was suppose to return images in a sorted order.
It does not because the for each is not coming back in the order of
the sorted "files" collection.
Imports System.Collections
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Sub Page_Load()
Dim pictures As New Hashtable
Dim filename As String = ""
Dim files As FileInfo() = New DirectoryInfo("c:\jjj\ppp
\pictures\").GetFiles()
Array.Sort(Of FileInfo)(files, AddressOf FileInfoComparison)
For Each fi As FileInfo In files
filename = fi.Name.ToLower()
If filename.EndsWith(".jpg") Then
pictures("pictures/" & filename) = "thumb.aspx?
src=pictures/" & filename
End If
Next
Repeater1.DataSource = pictures
Page.DataBind()
End Sub
Private Shared Function FileInfoComparison(ByVal fi1 As FileInfo,
ByVal fi2 As FileInfo) As Integer
'Return Date.Compare(fi1.LastWriteTime, fi2.LastWriteTime)
Return String.Compare(fi1.Name, fi2.Name)
End Function
any way around this? Thanks for any help or information!
It does not because the for each is not coming back in the order of
the sorted "files" collection.
Imports System.Collections
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Sub Page_Load()
Dim pictures As New Hashtable
Dim filename As String = ""
Dim files As FileInfo() = New DirectoryInfo("c:\jjj\ppp
\pictures\").GetFiles()
Array.Sort(Of FileInfo)(files, AddressOf FileInfoComparison)
For Each fi As FileInfo In files
filename = fi.Name.ToLower()
If filename.EndsWith(".jpg") Then
pictures("pictures/" & filename) = "thumb.aspx?
src=pictures/" & filename
End If
Next
Repeater1.DataSource = pictures
Page.DataBind()
End Sub
Private Shared Function FileInfoComparison(ByVal fi1 As FileInfo,
ByVal fi2 As FileInfo) As Integer
'Return Date.Compare(fi1.LastWriteTime, fi2.LastWriteTime)
Return String.Compare(fi1.Name, fi2.Name)
End Function
any way around this? Thanks for any help or information!