zoukankan      html  css  js  c++  java
  • 得到一个文件夹下的所有一个类型的文件

            List<string> ptotoList = new List<string>(); //路径字符串列表
            /// <summary>
            /// 得到一个文件夹下的所有一个类型的文件
            /// </summary>
            /// <param name="dicPath"></param>
            private void GetPtotoList(string dicPath)
            {
                try
                {
                    string[] files = System.IO.Directory.GetFiles(dicPath);
                    foreach (string file in files)
                    {
                        if (IsPicture(file))//在此是图片文件 具体自已写这个函数确认是什么类型文件
                        {
                            ptotoList.Add(file);
                        }
                    }
                    DirectoryInfo dir = new DirectoryInfo(dicPath);
                    foreach (DirectoryInfo subdir in dir.GetDirectories())
                    {
                        GetPtotoList(subdir.FullName);
                    }
                }
                catch
                { }
            }
  • 相关阅读:
    python 类
    python sys模块
    python os模块(2)
    python re模块
    python 最小公倍数
    python 最大公约数
    python datetime模块
    python 给定n,返回n以内的斐波那契数列
    python time模块
    python os模块(1)
  • 原文地址:https://www.cnblogs.com/houlinbo/p/1556723.html
Copyright © 2011-2022 走看看