How to list all final level of subfolders in a directory in vb.net? -


i have directory contains more 5000 subfolders....i need name of folders in final level.... i.e. sub-sub-sub...folders have no subfolders , list them in listbox.

but 1st level subfolders , 2nd...3rd.. still contain subfolders not needed listed...but last-level subfolders.

please me requirement.

try this:

public sub getchildfolders(sfolderpath string)     each dir string in io.directory.getdirectories(sfolderpath)         if io.directory.getdirectories(dir).length > 0             call getchildfolders(dir)         else             ' add "dir" listbox         end if     next end sub 

and call father directory starts:

call getchildfolders(startfolder) 

edit:

maybe rid of amount of folders:

dim alldirs() string = io.directory.enumeratedirectories(path, "*", system.io.searchoption.alldirectories)  each dir string in alldirs     if io.directory.getdirectories(dir).length = 0         ' add "dir" listbox     end if next 

Comments