// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; class MainClass { public static void Main(string[] args) { Console.WriteLine(TotalSize(@"C:\WINDOWS")); } public static long TotalSize(string dir) { long res = 0; DirectoryInfo d = new DirectoryInfo(dir); FileInfo[] allf = d.GetFiles(); for (int i = 0; i < allf.Length; i++) { res += allf[i].Length; } DirectoryInfo[] alld = d.GetDirectories(); for (int i = 0; i < alld.Length; i++) { res += TotalSize(alld[i].FullName); } return res; } }