zoukankan      html  css  js  c++  java
  • 图片下载(直接通过网站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;
            }

  • 相关阅读:
    Python爱心动画GIF
    R学习-8.Logic
    R学习-7.Matrices and Data Frames
    R学习-6.Subsetting Vectors
    R学习-5.Missing Values
    R学习-4.Vectors
    R学习-3.sequence of numbers
    R学习-2.Workspace and Files
    R学习-1.Basic Building Blocks
    通过生物学数据预测年龄-1
  • 原文地址:https://www.cnblogs.com/guozhe/p/2997560.html
Copyright © 2011-2022 走看看