I have a custom object that contains methods that returns all directory and file names in a root
string[] dirlist = obj.GetDirectories();
//which returns all dir names in root
string[] filelist = obj.GetFiles();
//which return all file names in root
I cannot modify these methods. Once I get the dirlist, how do i get a list of all subdirs in it as well as files in the subdirs, ignoring the security exceptions. It can be nested to multiple levels. Anything in .NET 4?
Update: string[] dirList can also be read as List dirlist. Please give a solution that uses the latest features of .NET
DirectoryOne
- SubDirOne
- SubDirTwo
- FileOne
- FileTwo
- SubDirThree
DirectoryTwo
DirectoryOne