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;
            }

  • 相关阅读:
    hdu5360 Hiking(水题)
    hdu5348 MZL's endless loop(欧拉回路)
    hdu5351 MZL's Border(规律题,java)
    hdu5347 MZL's chemistry(打表)
    hdu5344 MZL's xor(水题)
    hdu5338 ZZX and Permutations(贪心、线段树)
    hdu 5325 Crazy Bobo (树形dp)
    hdu5323 Solve this interesting problem(爆搜)
    hdu5322 Hope(dp)
    Lightoj1009 Back to Underworld(带权并查集)
  • 原文地址:https://www.cnblogs.com/tongdengquan/p/6090591.html
Copyright © 2011-2022 走看看