Counting the no. of Subdirectories

aroravicky

New member
Joined
Jun 23, 2004
Messages
2
Programming Experience
1-3
I need to count the no. of subdirectories in a directory. Can anybody suggest me how to do that.

Thanks in advance.

Regards,
Vikas
 

Radhakrishnan

Member
Joined
Jun 3, 2004
Messages
17
Location
Chennai - India
Programming Experience
5-10
Hi try this
Imports System.IO

Dim di As New DirectoryInfo("c:\")

Dim diArr As DirectoryInfo() = di.GetDirectories()

Dim dri As DirectoryInfo

Dim i As Integer

For Each dri In diArr

i += 1

Next dri

MessageBox.Show(i)

 

Neal

Forum Admin
Staff member
Joined
Jun 2, 2004
Messages
123
Location
VA
Programming Experience
10+
You may be able to name that tune in a few less notes:

dirArr.Length()
 

vbkev

Active member
Joined
Jun 4, 2004
Messages
32
Location
Newcastle, UK
Programming Experience
5-10
If System.IO.Directory.Exists("C:\MyDir") Then

MsgBox(System.IO.Directory.GetDirectories("C:\MyDir").Length())

End If

this is a slightly better way to do it as it checks the directory exists first
 
Top Bottom