David
Dim dirInfo As New DirectoryInfo(strPathPhy)
articleList.DataSource = dirInfo.GetFiles()
articleList.DataBind()
Looks like you need to specify the version of the framework if url doesn't
meet your need.
"David C" <dlc...@lifetimeinc.com> wrote in message
news:Og3YzWG3...@TK2MSFTNGP02.phx.gbl...
David
"sloan" <sl...@ipass.net> wrote in message
news:OBmFbkG3...@TK2MSFTNGP03.phx.gbl...
something like this, perhaps: (see at
http://www.siccolo.com/Articles/CodeProject/SelectFileDlg_SmartPhone/Smartphone_WM6_FileDialog.html)
...
Dim FileInfoComparer As FileInfoComparer = New FileInfoComparer()
Dim FileList() As FileInfo = ParentFolder.GetFiles()
Array.Sort(FileList, FileInfoComparer)
...
where
Public Class FileInfoComparer Implements
System.Collections.IComparer
Public Function Compare(ByVal objFileInfo1 As Object, ByVal
objFileInfo2 As Object) As Integer _
Implements IComparer.Compare
Dim FileInfo1 As System.IO.FileInfo = CType(objFileInfo1,
System.IO.FileInfo)
Dim FileInfo2 As System.IO.FileInfo = CType(objFileInfo2,
System.IO.FileInfo)
Return String.Compare(FileInfo1.Name, FileInfo2.Name, True)
End Function
End Class
more at http://www.siccolo.com/articles.asp
GridView1.Sort("FieldName", SortDirection)
HTH
S
"David C" <dlc...@lifetimeinc.com> wrote in message
news:Og3YzWG3...@TK2MSFTNGP02.phx.gbl...
> I'm assuming you mean a GridView control since I don't see a control on
> the Data tab called a DataGrid.
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
S
"Mark Rae [MVP]" <ma...@markNOSPAMrae.net> wrote in message
news:uB12qaI3...@TK2MSFTNGP03.phx.gbl...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim files As FileInfo() = New DirectoryInfo("c:\temp").GetFiles()
Array.Sort(Of FileInfo)(files, AddressOf FileInfoComparison)
articleList.DataSource = files
articleList.DataBind()
End If
End Sub
Private Shared Function FileInfoComparison(ByVal fi1 As FileInfo, ByVal
fi2 As FileInfo) As Integer
Return Date.Compare(fi1.LastWriteTime, fi2.LastWriteTime)
End Function
--
Milosz
thanks.
Imports System.Collections
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Sub Page_Load()
Dim pictures As New SortedList
Dim filename As String = ""
Dim i As Integer
Dim files As FileInfo() = New DirectoryInfo("c:\ppp\pictures
\").GetFiles()
Array.Sort(Of FileInfo)(files, AddressOf FileInfoComparison)
For i = 0 To files.Length - 1
filename = files(i).Name.ToLower()
If filename.EndsWith(".jpg") Then
pictures("pictures/" & filename) = "thumb.aspx?
src=pictures/" & filename
End If
Repeater1.DataSource = pictures
Page.DataBind()
Next
End Sub
Private Shared Function FileInfoComparison(ByVal fi1 As FileInfo,
ByVal fi2 As FileInfo) As Integer
Return Date.Compare(fi1.LastWriteTime, fi2.LastWriteTime)
End Function
End Class
Seems to me that you are sorting the list ok in files but then you are
creating a new SortedList which has nothing to do with the sort you did on
LastWriteTime. The list is most likely sorted on the keys.
LS
How can I loop through files in the new sorted order if not by the
index?
Any suggestion on fixing the code to do what I want?
Thanks.
Thanks.
You have the sorted list from the array sort. Use that array.
LS
Sorry.. I'm missing something here..
This line:
Array.Sort(Of FileInfo)(files, AddressOf FileInfoComparison)
is sorting the array "files" right?
How can I loop through "files" in the order it was sorted in using
vb.net?
thanks.. if possible can you paste the code?
This line:
Array.Sort(Of FileInfo)(files, AddressOf FileInfoComparison)
for each fi as FileInfo in files
do something
next
Imports System.Collections
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Sub Page_Load()
Dim pictures As New SortedList
Dim filename As String = ""
Dim files As FileInfo() = New DirectoryInfo("c:\jcp\pic
\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
End Class
I noticed if I use Hashtable instead of sortedlist I get yet another
order - neither correct ... I need to store the file names plus other
information for processing.. Sorry and Thanks any additional help.
The problem is the other collection (pictures). You sort and then when you
populate pictures your sort is destroyed. Make your datasource files and
you are ok. You will have to massage the info to get pictures/filename but
that is not much work.
LS