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);
                    }
                }

  • 相关阅读:
    Centos7安装docker-ce
    postgresql-11主从复制(流复制)部署
    centos7安装postgreSql11
    CentOS7下安装PostgreSQL12
    postgres生成uuid
    软工第一次团队展示
    软工第一次结对编程作业
    软工第一次个人编程作业
    课程总结
    团队作业
  • 原文地址:https://www.cnblogs.com/lxjshuju/p/7007000.html
Copyright © 2011-2022 走看看