You can enumerate the directories in a specific directory this way:
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Public Shared Function GetDirectories(directory As String) As String()
Dim list As New List(Of String)
list.AddRange
(
Directory.EnumerateDirectories
(
Path.Combine
(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
directory
)
)
)
Return list
.Select(p => Path.GetDirectoryName(p & "\"))
.ToArray()
End Function
Usage:
Dim paths As String() = GetDirectories("State of Decay 2 Mod Manager")
This is for the enumeration part.
Now, there is a remaining issue: why trying to populate the listbox on selected index changed? This event is fired whenever a distinct element in the list is selected. You would better populate this listbox just after the form has loaded, or whenever a change has been made to the contents of the base directory.