public static string FormatSize(double byteCount)
{
if (byteCount >= 1099511627776)
return String.Format("{0:##.##} TB", Math.Round(byteCount / 1099511627776, 1));
else if (byteCount >= 1073741824)
return String.Format("{0:##.##} GB", Math.Round(byteCount / 1073741824, 1));
else if (byteCount >= 1048576)
return String.Format("{0:##.##} MB", Math.Round(byteCount / 1048576, 0));
else if (byteCount >= 1024)
return String.Format("{0:##.##} KB", Math.Round(byteCount / 1024, 0));
else
return byteCount.ToString() + " bytes";
}