- 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];
- }
- //该片段来自于http://www.codesnippet.cn/detail/0104201512051.html
来源: http://www.codesnippet.cn/detail/0104201512051.html