1
This commit is contained in:
@@ -19,6 +19,34 @@ namespace BITKit
|
||||
public sealed class NetRpcAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 帮助类
|
||||
/// </summary>
|
||||
public static class NetUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算文件大小函数(保留两位小数),Size为字节大小
|
||||
/// </summary>
|
||||
/// <param name="size">初始文件大小</param>
|
||||
/// <returns></returns>
|
||||
public static string GetFileSize(long size)
|
||||
{
|
||||
var num = 1024.00; //byte
|
||||
|
||||
|
||||
if (size < num)
|
||||
return size + "B";
|
||||
if (size < Math.Pow(num, 2))
|
||||
return (size / num).ToString("f2") + "K"; //kb
|
||||
if (size < Math.Pow(num, 3))
|
||||
return (size / Math.Pow(num, 2)).ToString("f2") + "M"; //M
|
||||
if (size < Math.Pow(num, 4))
|
||||
return (size / Math.Pow(num, 3)).ToString("f2") + "G"; //G
|
||||
|
||||
|
||||
return (size / Math.Pow(num, 4)).ToString("f2") + "T"; //T
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 网络指令类型
|
||||
|
Reference in New Issue
Block a user