图片下载(直接通过网站url 下载图片)

 /// <summary>
        /// 图片下载
        /// </summary>
        /// <param name="imageList"></param>
        /// <param name="FileDir"></param>
        /// <returns></returns>
        private bool DownloadImage(List<string> imageList, string FileDir)
        {
            bool result = true;
            try
            {
                foreach (string str in imageList)
                {

                    if (str.IsMatch("(jpg|gif|png)$"))
                    {
                        Uri uri = new Uri(str);
                        FileInfo fi = new FileInfo(FileDir + uri.AbsolutePath);
                        if (!fi.Directory.Exists)
                        {
                            fi.Directory.Create();
                        }
                        //http://i04.c.aliimg.com/img/ibank/2012/618/641/715146816_109741793.jpg
                        if (!fi.Exists)
                        {
                            System.Net.WebClient wc = new System.Net.WebClient();
                            wc.DownloadFile(str, fi.FullName);
                        }

                    }

                }
            }
            catch
            {
                result = false;

            }
            finally
            {

            }
            return result;
        }

原文地址:https://www.cnblogs.com/guozhe/p/2997560.html