zoukankan      html  css  js  c++  java
  • 字节转b kb mb gb 等

     /// <summary>
            /// 计算文件大小函数(保留两位小数),Size为字节大小
            /// </summary>
            /// <param name="size">初始文件大小</param>
            /// <returns></returns>
            public static string GetFileSize(long size)
            {
                var num = 1024.00; //byte
                if (size < num)
                    return size + "B";
                if (size < Math.Pow(num, 2))
                    return (size / num).ToString("f2") + "K"; //kb
                if (size < Math.Pow(num, 3))
                    return (size / Math.Pow(num, 2)).ToString("f2") + "M"; //M
                if (size < Math.Pow(num, 4))
                    return (size / Math.Pow(num, 3)).ToString("f2") + "G"; //G
    
    
                return (size / Math.Pow(num, 4)).ToString("f2") + "T"; //T
            }
  • 相关阅读:
    tomcat-1
    oscache-2
    oscache-3
    oscache-1
    oscache-4
    缓存概要
    Criterion & DetachedCriteria
    Hibernate <查询缓存>
    Hibernate <二级缓存>
    Hibernate <一级缓存>
  • 原文地址:https://www.cnblogs.com/qc-id-01/p/9922742.html
Copyright © 2011-2022 走看看