Directory Counter : Directory : File Stream C# Source Code


Custom Search

C# Source Code » File Stream » Directory »

 

Directory Counter








    
 
using System;
using System.IO;
public class DirectoryCounter {
    public static void Main() {
        DirectoryInfo myDir = new DirectoryInfo(@"c:\Program Files");
        int total = CountDirectories(myDir);
        Console.WriteLine(total);
    }

    public static int CountDirectories(DirectoryInfo dir) {
        DirectoryInfo[] dirs = dir.GetDirectories();
        int count = dirs.Length;
        foreach (DirectoryInfo subDir in dirs) {
            count += CountDirectories(subDir);
        }
        return count;
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo File Stream
» Directory