Count number of files in a directory

stustarz

Well-known member
Joined
Jan 10, 2003
Messages
246
Location
Earth
Quick question - may not have an easy answer though.

Is there any way of counting the number of files inside a directory?
 
The GetFiles method of the Directory class returns an array of
Strings that contain filenames, so you can just check the length
of the array to get the number of files.

Code:
Dim numberOfFiles As Integer
Dim path As String = "c:\blah\"

numberOfFiles = System.IO.Directory.GetFiles(path).Length
 
Back
Top