字节转换 B,KB,MB,GB

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yeluo_vinager/article/details/72897492
 public string ConversionSize(long size)
        {
            double sizeD = size;
            if (sizeD < 1024)
                return sizeD.ToString("f1") + "B";
            sizeD = sizeD / 1024d;
            if (sizeD < 1024)
                return sizeD.ToString("f1") + "KB";
            sizeD = sizeD / 1024d;
            if (sizeD < 1024)
                return sizeD.ToString("f1") + "MB";
            sizeD = sizeD / 1024d;
            return sizeD.ToString("f1") + "GB";
        }

阅读更多

没有更多推荐了,返回首页