private static string[] units = { "B", "KB", "MB", "GB", "TB", "EB", "ZB", "YB" };
public static string FormatBytes(long bytes)
{
double db = bytes;
int level = 0;
while (db > 1024)
{
db /= 1024;
level++;
}
return db.ToString("0.##") + units[level];
}