1 long g = 1024 * 1024 * 1024; 2 long m = 1024 * 1024; 3 long k = 1024; 4 if (size < k && size >= 1) 5 { 6 ShowMsg(message + size.ToString("0.00") + "B"); 7 } 8 else if (size < m && size >= 1024) 9 { 10 ShowMsg(message + (size / k).ToString("0.00") + "KB"); 11 } 12 else if (size < g && size >= m) 13 { 14 ShowMsg(message + (size / m).ToString("0.00") + "MB"); 15 } 16 else if (size >= g) 17 { 18 ShowMsg(message + (size / g).ToString("0.00") + "GB"); 19 }
原文地址:http://www.cnblogs.com/gaobing/p/3851628.html