×

C# 格式化文件大

管理员 管理员 发表于2013-08-15 16:28:23 浏览3182 评论0

抢沙发发表评论

private static string[] units = { "B", "KB", "MB", "GB", "TB", "EB", "ZB", "YB" };

public static string FormatBytes(long bytes)

{

double db = bytes;

int level = 0;

while (db > 1024)

{

db /= 1024;

level++;

}

return db.ToString("0.##") + units[level];

}


群贤毕至

访客