Table of Contents

Class FileSizeExtensions

Namespace
MADE.Data.Converters.Extensions
Assembly
MADE.Data.Converters.dll

Defines a collection of extensions for converting byte values to human-readable file size representations.

public static class FileSizeExtensions
Inheritance
FileSizeExtensions
Inherited Members

Methods

ToHumanReadableFileSize(double, int)

Converts a byte count to a human-readable file size string using binary units (1 KB = 1024 bytes).

public static string ToHumanReadableFileSize(this double bytes, int decimalPlaces = 2)

Parameters

bytes double

The byte count to convert.

decimalPlaces int

The number of decimal places to display. Default is 2.

Returns

string

A human-readable file size string such as "1.50 MB" or "256 B".

ToHumanReadableFileSize(long, int)

Converts a byte count to a human-readable file size string using binary units (1 KB = 1024 bytes).

public static string ToHumanReadableFileSize(this long bytes, int decimalPlaces = 2)

Parameters

bytes long

The byte count to convert.

decimalPlaces int

The number of decimal places to display. Default is 2.

Returns

string

A human-readable file size string such as "1.50 MB" or "256 B".