/// <summary>字节单位换算</summary>
public static string ByteConversion(double length)
{
string temp;
if (length < 1024)
{
temp = Math.Round(length, 0) + "B";
}
else if (length < 1024 * 1024)
{
temp = Math.Round(length / (1024), 0) + "KB";
}
else if (length < 1024 * 1024 * 1024)
{
temp = Math.Round(length / (1024 * 1024), 2) + "MB";
}
else
{
temp = Math.Round(length / (1024 * 1024 * 1024), 2) + "GB";
}
return temp;
}版权声明:本文为a451319296原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。