I realize that I am using an older outdated version of Visual Studio, but I am having an issue with getting some files returned with Directory.GetFiles. I wrote a program that is a bible verse game. I am attempting to add another "mode" to the program that allows the users to just use the program as an open bible and read the verses from the book selected. The game part of the program works great and I do not have any issues. I added a combobox to my main form that gets loaded with the verses from the selected book when the user clicks a button. The chapters are in order in the directory (folder) of the respective book [ie: John1.txt, John2.txt, etc]. Using the code below, the chapters are being returned: [John1.txt, John10.txt, John11.txt...]
Private Sub LoadBook()
Dim CorrectVersePath As String = Nothing
Select Case My.Settings.Version
Case "KJV"
If My.Settings.TestamentName = "NewTestament" Then
Label2.Text = "New Testament"
CorrectVersePath = CorrectVersePath & KingJamesPath & "NewTestament\" & My.Settings.BookName & "\"
ElseIf My.Settings.TestamentName = "OldTestament" Then
Label2.Text = "Old Testament"
CorrectVersePath = CorrectVersePath & KingJamesPath & "OldTestament\" & My.Settings.BookName & "\"
End If
Case "NIV"
If My.Settings.TestamentName = "NewTestament" Then
Label2.Text = "New Testament"
CorrectVersePath = CorrectVersePath & NewInternationalPath & "NewTestament\" & My.Settings.BookName & "\"
ElseIf My.Settings.TestamentName = "OldTestament" Then
Label2.Text = "Old Testament"
CorrectVersePath = CorrectVersePath & NewInternationalPath & "OldTestament\" & My.Settings.BookName.ToString & "\"
End If
End Select
Dim Chapters = Directory.GetFiles(CorrectVersePath)
Dim chaptname As Array = Directory.GetFiles(CorrectVersePath)
For Each cname As String In chaptname
x += 1
ComboBox1.Items.Add(IO.Path.GetFileNameWithoutExtension(cname))
Next
End Sub
Is there a way to get those chapters returned in the order they are in the folder? I tried to use the Array.Sort function with the default configuration but it don't work. Yes I read this: