zoukankan      html  css  js  c++  java
  • 查询文件夹以及子文件夹下面的文件

     //获得院校相册图片,从college文件夹下查询所有子文件夹
            public List<string> ListFilesColleges(FileSystemInfo info)
            {
                List<string> image_list = new List<string>();
                if (!info.Exists) return null;
                DirectoryInfo dir = info as DirectoryInfo;
                //不是目录
                if (dir == null) return null;
                FileSystemInfo[] files = dir.GetFileSystemInfos();
                for (int i = 0; i < files.Length; i++)
                {
                    string son_folder_name = files[i].Name;//获取文件夹名称
                    DirectoryInfo dir_college = files[i] as DirectoryInfo;
                    FileSystemInfo[] file_college_name = dir_college.GetFileSystemInfos();//子文件夹里面的文件
                    if (file_college_name.Length > 0)
                    {
                        FileInfo file = file_college_name[0] as FileInfo;
                        string filename = file.Name;
                        string fileEx = filename.Substring(filename.LastIndexOf(".") + 1).ToLower();//后缀jpg jpeg gif bmp
                        if (fileEx == "jpg" || fileEx == "jpeg" || fileEx == "gif" || fileEx == "bmp")
                        {
                            image_list.Add(son_folder_name + "/" + file.Name);
                        }
                    }
                }
                return image_list;
            }

  • 相关阅读:
    第十八周个人作业
    十六周个人作业
    个人作业
    第十四周总结
    第十三周周末总结
    排球计分程序说明书
    我和计算机
    排球比赛记分员
    逻辑思维怎样成为一个高手
    用户故事排球教练助手
  • 原文地址:https://www.cnblogs.com/tongdengquan/p/6090591.html
Copyright © 2011-2022 走看看