tags:

views:

63

answers:

3

Hello all

I have some path , and i want to get from it only the subdirectories paths (i mean only paths that under them where not found another directories only files).

Any smart way to do so ?

Thanks a lot.

A: 

You can use the Directory.GetDirectories method.

However I'm not sure I understood your question correctly... could you clarify ?

Thomas Levesque
A: 

DirectoryInfo

DirectoryInfo dInfo = new DirectoryInfo(<path to dir>);
DirectoryInfo[] subdirs = dInfo.GetDirectories();
PoweRoy
A: 

It is my understanding that you want to list the subdirectories below a given path that contain only files.

static IEnumerable<string> GetSubdirectoriesContainingOnlyFiles(string path)
{
  return from subdirectory in Directory.GetDirectories(path, "*", SearchOption.AllDirectories)
         where Directory.GetDirectories(subdirectory).Length == 0
        select subdirectory;

}

Håvard S