Read in directory content in name order
In a program I am developing the locations of a directory on my computer are read in to an array. However the files in the array are arbitrarily ordered.
The code I have is:
Directorycontents = Directory.GetFiles("pathname")
how do make it so that they are sorted in order by file name?
Re: Read in directory content in name order
Take a look at this:
Code:
Dim pn As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim somelist As List(Of String) = IO.Directory.GetFiles(pn).ToList
somelist.Sort()
For Each item As String In somelist
Debug.WriteLine(item) 'full path
Debug.WriteLine(IO.Path.GetFileName(item)) 'just file name
Next
Re: Read in directory content in name order
I need a method that uses the current code I have sorry
Re: Read in directory content in name order
It would help to see the code you have. Sorry I guessed.