Added an information view to all data sources (#273)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2025-02-09 12:36:37 +01:00
1 parent 9d71978feb
commit c836bd7f33
61 files changed
+1596 -1372

No files matched your search

@@ -0,0 +1,22 @@
namespace AIStudio.Tools;
public static class LongExtensions
{
/// <summary>
/// Formats the file size in a human-readable format.
/// </summary>
/// <param name="sizeBytes">The size in bytes.</param>
/// <returns>The formatted file size.</returns>
public static string FileSize(this long sizeBytes)
{
string[] sizes = { "B", "kB", "MB", "GB", "TB" };
var order = 0;
while (sizeBytes >= 1024 && order < sizes.Length - 1)
{
order++;
sizeBytes /= 1024;
}
return $"{sizeBytes:0.##} {sizes[order]}";
}
}