惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
WordPress大学
WordPress大学
The Cloudflare Blog
云风的 BLOG
云风的 BLOG
博客园 - Franky
D
Docker
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
U
Unit 42
M
MIT News - Artificial intelligence
B
Blog
GbyAI
GbyAI
C
Check Point Blog
P
Proofpoint News Feed
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
雷峰网
雷峰网
IT之家
IT之家
Google DeepMind News
Google DeepMind News
V
V2EX
Stack Overflow Blog
Stack Overflow Blog

博客园 - HenryZhang

Javascript 使用类 用javascript按需加载.js和.css文件 考虑了全半角的SubString window.open 打开的窗口关闭后 javascript小技巧 看完越狱20件必须懂的东西(转) vs2005 安装sp1 NHibernate1.2在VS2005下的配置 AJAX第十一天 AJAX第十天 AJAX第九天 AJAX第七天 AJAX第八天 AJAX第六天 JavaScript常用正则表达式 JS正则表达式问题终于解决 Ajax第五天 Ajax第四天 除去所有在html元素中标记
上传文件时用到的显示文件大小
HenryZhang · 2007-01-24 · via 博客园 - HenryZhang

今天在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";
            }