Advertisement
kyrathasoft

count dirs recursively

May 22nd, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.25 KB | None | 0 0
  1.     public static int CountDirectories(string targetDirectory)
  2.     {
  3.         int iDirs = 0;
  4.        
  5.         if(Directory.Exists(targetDirectory)){
  6.             iDirs = Directory.GetDirectories(targetDirectory, "*", SearchOption.AllDirectories).Length;
  7.         }
  8.        
  9.         return iDirs;
  10.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement