代码
static string GetUnitNum(double num)
{
string[] unit = new string[] { "B", "KB", "MB", "GB", "TB" };
long n = 1024;
int i = 0;
while (num > n)
{
num /= n;
i++;
}
return Math.Round(num, 2) + unit[i];
}
评论区