PowerArgs.Cli.Friendlies.ToFriendlyFileSize C# (CSharp) Method

ToFriendlyFileSize() public static method

public static ToFriendlyFileSize ( long bytes ) : string
bytes long
return string
        public static string ToFriendlyFileSize(long bytes)
        {
            if(bytes < 1024)
            {
                return bytes + " B";
            }
            else if(bytes < 1024 * 1024)
            {
                var converted = Math.Round(bytes / 1024.0, 1);
                return converted + " KB";
            }
            else if (bytes < 1024 * 1024 * 1024)
            {
                var converted = Math.Round(bytes / (1024.0 * 1024.0) , 1);
                return converted + " MB";
            }
            else
            {
                var converted = Math.Round(bytes / (1024.0 * 1024.0 * 1024.0), 1);
                return converted + " GB";
            }
        }