判断图片格式

    private void CheckImage(string path)
        {
            MyService.Services ss = new MyService.Services();
            DirectoryInfo info = new DirectoryInfo(path);

            foreach (var item in info.GetDirectories())
            {
                string name = item.Name;
                foreach (var items in item.GetFiles())
                {
                    //name = info.Name;
                    string extension = items.Extension.ToLower();
                    string[] imgExtension = new string[] { ".jpg", ".gif", ".png", ".bmp", ".jpeg" };
                    bool isPic = false;
                    foreach (string itemf in imgExtension)
                    {
                        if (itemf == extension)
                        {
                            isPic = true;
                        }
                    }
         }

   }
 }

posted on 2012-01-11 14:15  风华之恋  阅读(223)  评论(0编辑  收藏  举报