文件大小转换

private static String HumanReadableFilesize(double size)
        {
            String[] units = new String[] { "B", "KB", "MB", "GB", "TB", "PB" };
            double mod = 1024.0;
            int i = 0;
            while (size>=mod )
            { size /= mod;
                i++;
            }
            return Math.Round(size) + units[i];

        }

posted @ 2014-11-25 11:23  星火卓越  阅读(129)  评论(0编辑  收藏  举报