日期:2014-05-17  浏览次数:21057 次

用webclient或者webrequest+webreponse获取网页图片为空白?
WebRequest request = WebRequest.Create(url);
            WebResponse reponse = request.GetResponse();
            long length = reponse.ContentLength;
            if (length < 10000)
            {
                reponse.Close();
                reponse.Dispose();
                return;
            }
            Stream reader = reponse.GetResponseStream();
            string pathname = path + (id + i++).ToString();
            pathname += post;
            FileStream write = new FileStream(pathname,FileMode.OpenOrCreate,FileAccess.ReadWrite);
            byte[] buff = new byte[2048];
            int c = 0;
            while ((c = reader.Read(buff, 0, buff.Length)) > 0)
                write.Write(buff,0,c);
            write.Close();
            write.Dispose();
            reader.Close();
            reader.Dispose();
            reponse.Close();
            reponse.Dispose();
以上是代码,为什么下载大于30K的图片时下载下来的图片为空白?
------解决方案--------------------
不知道。