zoukankan      html  css  js  c++  java
  • 通过Src下载图片存到指定目录

               string src = temppartsrc + "." + pictype;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(src);
                request.AllowAutoRedirect = true;

                WebProxy proxy = new WebProxy();
                proxy.BypassProxyOnLocal = true;
                proxy.UseDefaultCredentials = true;
                request.Proxy = proxy;
                WebResponse response = request.GetResponse();
                string virthpath = "";
                using (Stream stream = response.GetResponseStream())
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        Byte[] buffer = new Byte[1024];
                        int current = 0;
                        while ((current = stream.Read(buffer, 0, buffer.Length)) != 0)
                        {
                            ms.Write(buffer, 0, current);
                        }
                        byte[] arry = ms.ToArray();
                         virthpath = "./image/" + DateTime.Now.ToString("yyyyMMddhhmmss") + "." + pictype;
                        string path = Server.MapPath(virthpath);
                        File.WriteAllBytes(path, arry);
                    }
                }

  • 相关阅读:
    求一个二维数组的最大子矩阵(王伟光,曹锦锋)
    第二个冲刺周期第2天
    软件——第二个冲刺周期
    我的软件创意——历史上的今天
    我的ideas之网络安全——基于NABC模型
    电梯调度 最终版
    敏捷软件开发方法——scrum
    求一个二维数组中 子数组和的最大值
    电梯调度算法(二)
    结对项目开发-电梯调度(大体设计思路)
  • 原文地址:https://www.cnblogs.com/lxjshuju/p/7007000.html
Copyright © 2011-2022 走看看