How can I change this code to also enumerate sub directories?
var fqFilenames= new List<String>(System.IO.Directory.GetFiles(sMappedPath));
var filenames= fqFilenames.ConvertAll((s) => { return s.Replace(sMappedPath+"\\", ""); });
FileListView.DataSource = filenames;
Can you just use Directory.GetFiles(string, string, SearchOption)
? If not, please explain what you need which that doesn't cover.
For example:
Directory.GetFiles(sMappedPath, "*", SearchOption.AllDirectories)
Try looking at Directory.GetDirectories or the DirectoryInfo equivalent. The example on the linked page shows recursively traversing subdirectories
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With