Results 1 to 3 of 3

Thread: Sorting Files

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    5

    Sorting Files

    i want to sort files by what is actually in the files rather than just by their name. I have the following which sorts them by their name:

    Code:
    Private Sub SortFilesAzimuth()
            Dim flbs(FilesLB.Items.Count - 1) As FileListBoxItem
            FilesLB.Items.CopyTo(flbs, 0)
    
            Dim dt As New DataTable()
            dt.Columns.Add(New DataColumn("OrigIndex", System.Type.GetType("System.Int32")))
            dt.Columns.Add(New DataColumn("FileIndex", System.Type.GetType("System.Int32")))
    
            For i As Integer = 0 To flbs.Length - 1
                Dim r As DataRow = dt.NewRow
                r("OrigIndex") = i
                r("FileIndex") = flbs(i).Index
                dt.Rows.Add(r)
            Next
    
            Dim dv As New DataView(dt)
            dv.Sort = "FileIndex ASC"
            For i As Integer = 0 To dv.Count - 1
                Dim flb As FileListBoxItem = flbs(CType(dv(i)("OrigIndex"), Integer))
                Me.FilesLB.Items.Remove(flb)
                Me.FilesLB.Items.Insert(i, flb)
            Next
    
        End Sub
    I have numbers in the files I want to sort them by and not by the name of the file. Can anyone give me any suggestions?

    Thanks

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Sorting Files

    Welcome to the forums!

    This is .Net, isn't it? I'll move it to the .Net forum, not the Classic which is for versions 6 and older


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    5

    Re: Sorting Files

    yes, cheers!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width