예제 #1
0
        public static string GetSizeInAutoString(long value, ComputerSizeUnits b)
        {
            if (b != ComputerSizeUnits.B)
            {
                // Získám hodnotu v bytech
                value = ConvertToSmallerComputerUnitSize(value, b, ComputerSizeUnits.B);
            }


            if (value < 1024)
            {
                return(value + " B");
            }

            double previous = value;

            value /= 1024;

            if (value < 1)
            {
                return(previous + " B");
            }

            previous = value;
            value   /= 1024;

            if (value < 1)
            {
                return(previous + " KB");
            }

            previous = value;
            value   /= 1024;
            if (value < 1)
            {
                return(previous + " MB");
            }

            previous = value;
            value   /= 1024;

            if (value < 1)
            {
                return(previous + " GB");
            }

            return(value + " TB");
        }
예제 #2
0
 private static long ConvertToSmallerComputerUnitSize(long value, ComputerSizeUnits b, ComputerSizeUnits to)
 {
     return(ConvertToSmallerComputerUnitSize(value, b, to));
 }