This code shows all the names within a top-level directory. This is not my code, and I'd give credit to whomever wrote it, but I haven't the foggiest.
Dim MyPath As String
Dim MyName As String
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Console.WriteLine(MyName) ' Display entry only if it
End If ' it represents a directory.
End If
MsgBox(MyName)
MyName = Dir() ' Get next entry.
Loop
I hope this helps.
Ron
Ron Repp