This page should cater to your needs. They show code for a function that recursively lists all files in directory and all sub directories:
Recursive directory function in VB.NET[^]
They return a List
, but you can turn that into an array with the List.ToArray()
method. I would not do that though because it's so easy to search in a List using the Predicate delegate. Look that up on MSDN: List.Find
& List.FindAll
Please refer to SAKryukov's answer, it is the best solution in this case as it relies solely on already built in .NET functions plus you get your files in an array as per your request (or requirement).
If you already looked up
List.Find
and
List.FindAll
and would like to use it, you can create a list from an array and then back again should the need arise:
List<String> myList = new List<String>(theArrayFromTheGetFilesCall);
Hope that helps you!
Best Regards,
Manfred