May
12
Apparently this proved a challenge for google, so I converted and simplified some PHP code I found.
This method will turn any byte into a human readable string, handy when dealing with files.
public string ConvertBytes(long Bytes)
{
string[] units = new string[] { "Bytes", "KB", "MB", "GB", "TB", "PB" };
int i;
for (i = 0; Bytes > 1024; i++) { Bytes /= 1024; }
return Bytes.ToString() + " " + units[i];
}