public static string BytesToString(ulong bytes) { const float gb = 1024 * 1024 * 1024; const float mb = 1024 * 1024; const float kb = 1024; string result; if (bytes > gb) { result = StringFormat.Float(bytes / gb) + " GB"; } else if (bytes > mb) { result = StringFormat.Float(bytes / mb) + " MB"; } else if (bytes > kb) { result = StringFormat.Float(bytes / kb) + " KB"; } else { result = StringFormat.Float((float)bytes) + " bytes"; } return(result); }