You can use this piece of C# code to do this:
using System;
class Test
{
public static void Main(string[]args)
{
Console.WriteLine(GetSize(int.Parse(args[0])));
}
public static string GetSize(long size)
{
double s = size;
string[] format = new string[] {"{0} bytes", "{0} MB", "{0} GB", "{0} TB", "{0} PB", "{0} EB"};
int i = 0;
while (i < format.Length && s >= 1024) {
s = (int) (100 * s / 1024) / 100.0;
i++;
}
return string.Format(format[i],s);
}
}