Advertisement
H4x0

Count Directories

Aug 22nd, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.40 KB | None | 0 0
  1. /*
  2.  * Can't gaurentee this works correctly since i am not
  3.  * near my compiler and am writing it freehand in Pastebin
  4.  * but in theory it should work.
  5.  */
  6. int countDirectories(string Dir)
  7. {
  8.     int retVal = 0;
  9.     string[] Names = Dir.Split('\');
  10.  
  11.    //If you want to include the root ( ex. f:\ )
  12.    return Names.Count;
  13.  
  14.    //If you don't want to include the root
  15.     return Names.Count - 1;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement