DesktopHelper.UI.ClearSystemGarbageForm.ConvertSize C# (CSharp) Метод

ConvertSize() приватный Метод

private ConvertSize ( long byteSize ) : string
byteSize long
Результат string
        private string ConvertSize(long byteSize)
        {
            string str = string.Empty;
            try
            {
                float tempf = (float)byteSize;
                if (tempf / 1024 > 1)
                {
                    if (((tempf / 1024) / 1024) / 1024 > 1)
                    {
                        str = (((tempf / 1024) / 1024) / 1024).ToString("##0.00", CultureInfo.InvariantCulture) + "GB";
                    }
                    else if ((tempf / 1024) / 1024 > 1)
                    {
                        str = ((tempf / 1024) / 1024).ToString("##0.00", CultureInfo.InvariantCulture) + "MB";
                    }
                    else
                    {
                        str = (tempf / 1024).ToString("##0.00", CultureInfo.InvariantCulture) + "KB";
                    }
                }
                else
                {
                    str = tempf.ToString(CultureInfo.InvariantCulture) + "B";
                }
            }
            catch(Exception ex)
            {
                log.WriteLog(ex.ToString());
            }
            return str;
        }