How to search a folder with its subfolders and save the results to an array VB.NET -
i trying execute search on folder , array of every result back. found code doesn't go subfolders:
dim results new list(of string) each strfilename string in io.directory.getfiles("pathtosearch") if strfilename.contains("searchterm") results.add(strfilename) end if next
how can this, subfolders?
i'm not knowledgeable search options in vb.net yet, apologize in advance if seems stupid. have tried searching online haven't found anything. can't have single string, needs array (this needs interpreted machine later in program)
thanks help
no recursion required. there overload this. need call appropriate search option.
e.g. list txt files in directory subdirectories can do:
dim foundfiles() string = system.io.directory.getfiles("path/to/dir", "*.txt", system.io.searchoption.alldirectories)
Comments
Post a Comment