• 通过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);
                    }
                }

  • 相关阅读:
    常用正则搜集(已验证)
    oracle 如何跨用户查询数据
    SVN状态图标消失的解决方法
    oracle 简单列操作
    正则替换行尾,行末内容
    怎么解决svn清理失败且路径显示乱码问题
    Oracle坑爹入门踩坑篇
    如何过滤datable?
    JS产生模态窗口,关闭后刷新父窗体。(兼容各浏览器)
    6 Jmeter脚本组成和组件搭配
  • 原文地址:https://www.cnblogs.com/lxjshuju/p/7007000.html
Copyright © 2020-2023  润新知