AA2Install.formMain.BytesToString C# (CSharp) Method

BytesToString() private method

Converts a length of bytes into a human readable form.
private BytesToString ( long bytes ) : string
bytes long The amount of bytes.
return string
        private string BytesToString(long bytes)
        {
            string[] sizes = { "B", "KB", "MB", "GB" };
            double len = bytes;
            int order = 0;
            while (len >= 1024 && order + 1 < sizes.Length)
            {
                order++;
                len = len / 1024;
            }

            return string.Format("{0:0.##} {1}", len, sizes[order]);
        }