Question on SortedFileList

flash.tato

Member
Joined
Aug 26, 2006
Messages
8
Programming Experience
Beginner
I need merging into one file container many file.

But they must be merged in alphabetical order.

I tried using SortedFileList but it doesn't work :confused: and i don't understand why

The code is
------------------------------------------------------------------------
VB.NET:
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox2.Text = "Software opened!!!"
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            TextBox1.Text = FolderBrowserDialog1.SelectedPath
            TextBox2.Text = "Directory selected!!!"
        End If
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If TextBox1.Text = "" Then
                TextBox2.Text = "Error!No Directory selected"
            Else
                Dim SortedFileList As New SortedList
                For Each item As String In My.Computer.FileSystem.GetFiles(Me.TextBox1.Text, FileIO.SearchOption.SearchTopLevelOnly, "*.gif")
                    SortedFileList.Add(item, item)
                Next
                For Each item As String In My.Computer.FileSystem.GetFiles(Me.TextBox1.Text, FileIO.SearchOption.SearchTopLevelOnly, "*.gif")
                    For Each s1 As String In SortedFileList
                        My.Computer.FileSystem.WriteAllBytes(s1, My.Computer.FileSystem.ReadAllBytes(item), True)
                        TextBox2.Text = "File Container Building!!!"
                    Next
                    TextBox2.Text = "File Container Made!!!"
                Next
            End If
        End If
    End Sub
End Class

But i don't understand why doesn't it merge files in alphabetical order?!

How do i solve it?!
 
do you mean you wish to list the names of many files, from many different directories, and then sort them by name?

do you want literal alphabetical sorting, or do you want intuitive numerical sorting?

i.e.

file1.txt
file10.txt
file2.txt

or

file1.txt
file2.txt
file10.txt
 
Back
Top