Get all folder / directories list in VB.net
- by Henry
Hi, this is my first Stackoverflow question, im learning VB and having a few problems with getting a list of all folders/directories on the system, im using the code included here and it seems to work until it hits the recycle bin folder, and some other system folders
Sub main()
Dim DirList As New ArrayList
GetDirectories("c:\", DirList)
For Each item In DirList
'add item to listbox or text etc here
Next
End sub
End Sub
Sub GetDirectories(ByVal StartPath As String, ByRef DirectoryList As ArrayList)
Dim Dirs() As String = Directory.GetDirectories(StartPath)
DirectoryList.AddRange(Dirs)
For Each Dir As String In Dirs
GetDirectories(Dir, DirectoryList)
Next
End Sub
Can anyone help me with this, id like to know what is causing this first, and a good fix, or alternative way to do this.
Thanks in advance.