I'm trying to write a FileIterator class, and what I need to do is list all the files in any given pathway include all subdirectories, digging as far as the hierarchy goes. See my code below, and the problem is that it only searches down one level of the folder structure.
Any help appreiated
Any help appreiated
VB.NET:
Private Sub populate(ByVal includeSubDirs As Boolean)
Dim dirRoot As New DirectoryInfo(pathway)
Dim subDirs() As DirectoryInfo
Dim dir As DirectoryInfo
Dim fileList() As FileInfo
'root Dir files
fileList = dirRoot.GetFiles
addFilesInThisDir(fileList)
'include subDirs?
If Not includeSubDirs Then Exit Sub
'set subDirs
subDirs = dirRoot.GetDirectories '??? thisonly digs down 1 level :mad:
'sub Dir level 1
For Each dir In subDirs
If dirIsValid(dir) Then 'all this does is ignore sys/hidden folders
fileList = dir.GetFiles
addFilesInThisDir(fileList)
End If
Next dir
End Sub
Last edited by a moderator: