バイト数の表記を追加する

このコミットが含まれているのは:
routersys committed 2026-09-13 17:52:29 +09:00
1 親 2eda014f27
コミット c765a51567
1ファイル変更
+24
+24
ファイルの表示
@@ -0,0 +1,24 @@
using System.Globalization;
namespace ProxyForge.ViewModels;
internal static class ByteText
{
static readonly string[] Units = ["B", "KB", "MB", "GB", "TB"];
public static string Format(long bytes)
{
if (bytes <= 0)
return "0 B";
double value = bytes;
var order = 0;
while (value >= 1024d && order < Units.Length - 1)
{
value /= 1024d;
order++;
}
return string.Create(CultureInfo.InvariantCulture, $"{value:0.##} {Units[order]}");
}
}