/// <summary>
/// 计算文件大小函数(保留两位小数),Size为字节大小
/// </summary>
/// <param name="Size">初始文件大小</param>
/// <returns></returns>
public static string CountSize(long Size)
{
string m_strSize = "";
long FactSize = 0;
FactSize = Size;
if (FactSize < 1024.00)
m_strSize = FactSize.ToString("F2") + " Byte";
else if (FactSize >= 1024.00 && FactSize < 1048576)
m_strSize = (FactSize / 1024.00).ToString("F2") + " K";
else if (FactSize >= 1048576 && FactSize < 1073741824)
m_strSize = (FactSize / 1024.00 / 1024.00).ToString("F2") + " M";
else if (FactSize >= 1073741824)
m_strSize = (FactSize / 1024.00 / 1024.00 / 1024.00).ToString("F2") + " G";
return m_strSize;
}
C# 计算文件大小函数(保留两位小数),Size为字节大小
最新推荐文章于 2019-07-14 22:54:54 发布