コード例 #1
0
 public void FolderSize()
 {
     DirectoryInfo dir = Directory.GetParent("..\\..\\TestDirectory");
     DirectoryTree dirTree = new DirectoryTree(dir.FullName + "\\TestDirectory");
     double size = dirTree.CalculateSizeOfFolder("4");
     Assert.IsTrue(size >= 2d && size < 2.1d);
 }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Tree is building, please wait for few seconds...");
            DirectoryTree dirTree = new DirectoryTree("C:\\Windows");

            Console.WriteLine("Done.");

            Console.WriteLine("\nTree size: ");
            double sizeInMB = dirTree.CalculateSizeOfTree();
            Console.WriteLine("{0} megabytes", sizeInMB);
            Console.WriteLine("{0} or gigabytes", sizeInMB / 1024);

            //in windows 8 AppCompat exists, you can try any other folder in Windows directory
            Console.WriteLine("\nCalculate size of tree folder and subfolders: ");
            sizeInMB = dirTree.CalculateSizeOfFolder("AppCompat");
            Console.WriteLine("{0} megabytes", sizeInMB);
            Console.WriteLine("{0} or gigabytes", sizeInMB / 1024);

        }