Does .NET provide an easy way convert bytes to KB, MB, GB, etc.?

Here is a fairly concise way to do this: static readonly string[] SizeSuffixes = { “bytes”, “KB”, “MB”, “GB”, “TB”, “PB”, “EB”, “ZB”, “YB” }; static string SizeSuffix(Int64 value, int decimalPlaces = 1) { if (decimalPlaces < 0) { throw new ArgumentOutOfRangeException(“decimalPlaces”); } if (value < 0) { return “-” + SizeSuffix(-value, decimalPlaces); } if … Read more