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

  • 相关阅读:
    仿jquery 选择器功能
    多个div拖拽功能
    js 模拟jquery onready 事件
    随着鼠标移动的图片百叶窗效果
    计算体重引发的思考
    js 模拟事件
    表单验证功能(利用冒泡功能)
    视频播放滚动条(最终完善版)
    仿制视频播放滚动条效果(加左右控制按钮)
    无极树(待整理)
  • 原文地址:https://www.cnblogs.com/lxjshuju/p/7007000.html
Copyright © 2011-2022 走看看