vb.net - List all folders that are in any 3rd subdirectory from current -


i need make array list, displaying folders in 3rd subfolder current one.

folder1/sub1folder/sub2folder/sub3folder 

it has recursive. need array of strings contains strings above. know how recursively folders, not know how limit search 3rd subfolder.

thanks!

here's stab @ it. tested , works me:

dim resultlist list(of string) = directorysearch(basedirectorypath, 0)  function directorysearch(directorypath string, level integer) list(of string)      level += 1      dim directories string() = io.directory.getdirectories(directorypath)      dim resultlist new list(of string)      if level = 3         each subdirectorypath in directories             dim result string = getfinalresult(subdirectorypath)             resultlist.add(result)         next     else         each subdirectorypath in directories             dim partialresultlist list(of string) = directorysearch(subdirectorypath, level)             resultlist.addrange(partialresultlist)         next     end if      return resultlist  end function  private function getfinalresult(directorypath string) string     dim directoryinfo new io.directoryinfo(directorypath)     return string.format("{0}/{1}/{2}/{3}",                          directoryinfo.parent.parent.parent.name,                          directoryinfo.parent.parent.name,                          directoryinfo.parent.name,                          directoryinfo.name) end function 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -