网上地址下载图片2

        public void temp1()
        {
            string strURL = "http://McH2N0M1PCn1QYh8";
            string strName = "download.jpg";
            System.Net.WebClient myWebClient = new System.Net.WebClient();
            string name = Server.MapPath(strName);
            myWebClient.DownloadFile(strURL, name);
        }
        public void temp2()
        {
            const string filePath = @"E:\\a.jpg";
            Uri rl = new Uri("http://file2N0M1PCn1QYh8");
           
                using (WebClient wc = new WebClient())
                {
                    wc.DownloadFile(rl, filePath);

                    //string html = wc.DownloadString(url);
                    //using (StreamWriter writer = new StreamWriter(filePath, false, wc.Encoding))
                    //{
                    //    writer.Write(html);
                    //    writer.Flush();
                    //}
                }
       }

  

posted @ 2014-03-21 17:34  心绪如泥  阅读(129)  评论(0编辑  收藏  举报