Reputation: 381
Is there any efficient way on C# to determine whether exists subfolder with name 'sub' in any level of the folder.
Means, given path I would like to determine if there is any level on the subtree of path which contais folder 'sub'.
Thanks!
Upvotes: 1
Views: 49
Reputation: 15982
You can use Directory.GetDirectories()
or Directory.EnumerateDirectories()
methods, specifying that includes the current directory and all its subdirectories in a search operation:
var subDirs = Directory.GetDirectories("ROOT PATH", "sub", SearchOption.AllDirectories);
Upvotes: 3