Skip to main content

Introduction

Vali-FileSize is a lightweight, zero-dependency .NET library for converting and formatting file sizes across all major units.

Why Vali-FileSize?

Working with raw byte counts in real-world applications is tedious. Displaying 1572864000 to a user is meaningless — 1.46 GB is not. Vali-FileSize handles this conversion cleanly with a minimal API that adapts to your formatting needs.

Key capabilities

FeatureDescription
Unit conversionConvert between any two units in a single call
Smart formattingHuman-readable strings with decimal precision control
Auto unit detectionGetBestUnit selects the most appropriate unit automatically
IEC binary prefixesFull support for KiB, MiB, GiB, TiB, PiB, EiB
Extension methodsdouble and long extensions for minimal boilerplate
Dependency injectionIValiFileSize interface for clean DI registration
Multi-frameworknetstandard2.0, netstandard2.1, net6.0, net7.0, net8.0, net9.0

Supported units

Traditional binary units

Bytes · Kilobytes (KB) · Megabytes (MB) · Gigabytes (GB) · Terabytes (TB) · Petabytes (PB) · Exabytes (EB)

IEC binary units

Kibibytes (KiB) · Mebibytes (MiB) · Gibibytes (GiB) · Tebibytes (TiB) · Pebibytes (PiB) · Exbibytes (EiB)

All conversions use the binary base (1 unit = 1 024 of the previous).