获取一个文件夹的大小

 static protected internal long CountFolderLength(string FolderPath)
        {
            long folder_length = 0;

            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(FolderPath);
            System.IO.FileInfo[] fis = di.GetFiles();

            foreach (System.IO.FileInfo fi in fis)
                folder_length += fi.Length;

            System.IO.DirectoryInfo[] dis = di.GetDirectories();

            foreach (System.IO.DirectoryInfo cdi in dis)
            {
                folder_length += CountFolderLength(cdi.FullName);
            }

            return folder_length;
        }

原文地址:https://www.cnblogs.com/sskset/p/515233.html