1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
public string ToFuzzyByteString(long bytes)
{
double s = bytes;
string[] format = new string[]
{
"{0} bytes", "{0} KB",
"{0} MB", "{0} GB", "{0} TB", "{0} PB", "{0} EB"
};
int i = 0;
while (i < format.Length && s >= 1024)
{
s = (long) (100*s/1024)/100.0;
i++;
}
return string.Format(format[i], s);
}
|