I don't believe there is anything like that in .NET. Here's the key part of a PowerShell script I have to do this for me.
$prefixes = @('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
$base = 1024;
$magnitude = [Math]::Floor([Math]::Log($_, 1024))
Write-Verbose "`$magnitude = $magnitude"
if($magnitude -eq 0)
{
[string]$mantissa = $_
[string]$label = 'B';
}
else
{
[string]$mantissa = [String]::Format("{0:N}", $_ / [Math]::Pow(1024, $magnitude))
Write-Verbose "`$mantissa = $mantissa"
[string]$label = $prefixes[$magnitude]
if ($IEC)
{
$label += "i"
}
$label += $unit
}
[String]::Format("{0} {1}", $mantissa, $label)
It needs to be updated to use PowerShell V2's Advanced Functions. (The parts that I didn't paste in are the parts that try to do what Advanced Functions do, and it's messy.)