How to list files + folders recursively using System.IO.Directory.GetFiles

How can I modify this code to also list auxiliary directories?

var fqFilenames= new List<String>(System.IO.Directory.GetFiles(sMappedPath)); var filenames= fqFilenames.ConvertAll((s) => { return s.Replace(sMappedPath+"\\", ""); }); FileListView.DataSource = filenames; 
+4
source share
2 answers

Can you just use Directory.GetFiles(string, string, SearchOption) ? If not, explain what you need, what does not apply.

For instance:

 Directory.GetFiles(sMappedPath, "*", SearchOption.AllDirectories) 
+20
source

Try to find Directory.GetDirectories or the equivalent of DirectoryInfo. The example on the linked page shows the recursive movements of subdirectories

+4
source

All Articles