views:

455

answers:

2

How to 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;
+4  A: 

Try looking at Directory.GetDirectories or the DirectoryInfo equivalent. The example on the linked page shows recursively traversing subdirectories

Gishu
+9  A: 

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)
Jon Skeet