码迷,mamicode.com
首页 > 其他好文 > 详细

获取指定路径下的所有图片文件名

时间:2015-09-09 12:53:24      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace File_Test
{
    class GetImages
    {


        /// <summary>
        /// 获取指定的文件夹中的图片文件
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public string[] GetAllImages(string path)
        {
            List<string> imagesPath = new List<string>(); ;
            string[] strs = System.IO.Directory.GetFiles(path);

            foreach (string file in strs)
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(file);

                if (fi.Extension == ".jpg" || fi.Extension == ".gif" || fi.Extension == ".bmp")
                {
                    imagesPath.Add(fi.Name);
                }
            }
            return imagesPath.ToArray();
        }
    }

}

 

获取指定路径下的所有图片文件名

标签:

原文地址:http://www.cnblogs.com/mfc-itblog/p/4794132.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!