字节b换算kb/mb/gb/tb/pb

public 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, 2) + units[i];
}

posted @ 2016-04-28 11:11  Logan_626  阅读(582)  评论(0编辑  收藏  举报