Sdl.Web.Common.Models.MediaItem.GetFriendlyFileSize C# (CSharp) Method

GetFriendlyFileSize() public method

Gets the file size with units.
public GetFriendlyFileSize ( ) : string
return string
        public string GetFriendlyFileSize()
        {
            string[] sizes = { "B", "KB", "MB", "GB", "TB", "PB", "EB" };
            double len = FileSize;
            int order = 0;
            while (len >= 1024 && order + 1 < sizes.Length)
            {
                order++;
                len = len / 1024;
            }

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