ByteFlow.Net
0.2.0
dotnet add package ByteFlow.Net --version 0.2.0
NuGet\Install-Package ByteFlow.Net -Version 0.2.0
<PackageReference Include="ByteFlow.Net" Version="0.2.0" />
<PackageVersion Include="ByteFlow.Net" Version="0.2.0" />
<PackageReference Include="ByteFlow.Net" />
paket add ByteFlow.Net --version 0.2.0
#r "nuget: ByteFlow.Net, 0.2.0"
#:package ByteFlow.Net@0.2.0
#addin nuget:?package=ByteFlow.Net&version=0.2.0
#tool nuget:?package=ByteFlow.Net&version=0.2.0
<p align="center"> <img src="https://raw.githubusercontent.com/AndrewClements84/ByteFlow.Net/master/assets/logo.png" alt="ByteFlow.Net Logo" width="200"/> </p>
ByteFlow.Net
ByteFlow.Net — Convert bytes ⇄ human-readable formats with SI, IEC, culture-aware, and customizable units. Zero dependencies.
✨ Features
- Convert raw byte counts into human-readable strings (e.g.
1234567 → "1.23 MB") - Parse human-readable strings back into bytes (
"2.5 GB" → 2684354560) - Safe parsing via
TryParseHumanBytes(no exception) - Support for both IEC (KiB, MiB, GiB) and SI (KB, MB, GB) unit standards
- Culture-aware parsing/formatting (e.g.
"1,5 MB"for cultures with comma decimal separators) - Customizable suffix sets (allow defining your own unit names/factors)
- Alignment/padding helpers for nicely formatted output in tables or logs
- Fully tested with 100% code coverage
- Zero external dependencies — pure C#
📦 Installation
Install via NuGet:
dotnet add package ByteFlow.Net
🚀 Usage
using ByteFlow;
// Basic conversion
long size = 1234567;
Console.WriteLine(size.ToHumanBytes()); // e.g. "1.18 MB" (default settings)
Console.WriteLine(size.ToHumanBytes(3)); // more decimals
// Parsing string to bytes
long bytes = "2.5 GB".ToBytes(); // default parsing (SI/IEC based on default)
Console.WriteLine(bytes);
// Safe parsing
if ("10 MB".TryParseHumanBytes(out var val))
{
Console.WriteLine(val); // prints bytes if successful
}
// Using IEC explicitly
Console.WriteLine(1536L.ToHumanBytes(2, UnitStandard.IEC)); // "1.50 KiB"
long val2 = "1.50 KiB".ToBytes(UnitStandard.IEC);
// Culture-aware parsing/formatting
var de = new System.Globalization.CultureInfo("de-DE");
Console.WriteLine((1500L).ToHumanBytes(2, UnitStandard.SI, de)); // "1,50 KB"
long val3 = "1,50 KB".ToBytes(UnitStandard.SI, de);
// Custom suffix sets
var custom = new[] { ("X", 1d), ("KX", 1000d), ("MX", 1000000d) };
string customStr = 5000L.ToHumanBytes(2, UnitStandard.SI, null, custom); // "5.00 KX"
long customBytes = "5 KX".ToBytes(UnitStandard.SI, null, custom);
🧪 Unit Tests & Code Coverage
Unit tests are under ByteFlow.Tests (xUnit).
Run them with:
dotnet test
Coverage is tracked via Codecov — current coverage: 100% ✅
🧭 Alternatives / Comparisons
While there are other “bytes to human readable” .NET libraries out there, very few (if any) offer the combined feature set that ByteFlow.Net does:
- Support for both IEC and SI
- Culture-aware parsing/formatting
- Fully customizable suffix sets
- Alignment/padding helpers
- Zero dependencies
- Complete test coverage
So this library aims to be a robust one-stop solution for byte-size formatting.
🤝 Contributing
Contributions, issues, and feature requests are always welcome!
Feel free to open a discussion or a pull request.
⭐ Support
If you enjoy using ByteFlow.Net, a GitHub star helps more than you’d think — it boosts visibility and helps others find it.
📄 License
Licensed under the MIT License — see LICENSE.txt for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.