首页 新闻 会员 周边

有时候获取不到response.ContentLength,偶尔又能获取到了

0
悬赏园豆:10 [待解决问题]
     /// <summary>
        /// 获取文件总大小
        /// </summary>
        public void GetTotalSize()
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(this.url);
            //request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-silverlight-2-b1, */*";
            request.ContentType = "application/x-www-form-urlencoded";
            request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0";
            WebResponse response = request.GetResponse();
            request.Method = "HEAD";
            request.Timeout = 5000;  
            this.totalSize = response.ContentLength;

        }
fullSunlight的主页 fullSunlight | 菜鸟二级 | 园豆:232
提问于:2016-04-13 10:37
< >
分享
所有回答(1)
0

应该是没获取到文件

小光 | 园豆:1766 (小虾三级) | 2016-04-13 11:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册