我有一些路径,我想从它只是子目录路径得到(我的意思只是说在他们那里没有发现其它目录中的文件路径)。
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 ?
多谢了。
这是我的理解是要列出一个给定的路径下只包含文件的子目录。
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;
}