This commit is contained in:
CortexCore
2024-06-17 14:38:09 +08:00
parent 3d447499fe
commit 65f9e40105
8 changed files with 86 additions and 14 deletions

View File

@@ -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>
/// 网络指令类型