今天在QQ群里有人发了个不错的方法,以前写这个总觉得麻烦,下面这个确实不错

if (num1 > "G的单位")
            {
                text2 = Math.Round(((double) num1) / 1073741824, 2) + " GB";
            }
            else if (num1 > "M的单位")
            {
                text2 = Math.Round(((double) num1) / 1048576, 2) + " MB";
            }
            else if (num1 > "K的单位")
            {
                text2 = Math.Round(((double) num1) / 1024, 2) + " KB";
            }
            else
            {
                text2 = num1 + " Byte";
            } 

posted on 2007-01-24 11:03  HenryZhang  阅读(310)  评论(0编辑  收藏  举报