zoukankan      html  css  js  c++  java
  • 【原创】C# 递归获取指定目录的子目录及其所有文件

    public static void FindFile(string dirPath) //参数dirPath为指定的目录
        {

            //在指定目录及子目录下查找文件,在listBox1中列出子目录及文件

            DirectoryInfo Dir = new DirectoryInfo(dirPath);

            try
            {

                foreach (DirectoryInfo d in Dir.GetDirectories()) //查找子目录
                {

                    FindFile(Dir + d.ToString() + "\\");

                    listBox1.Items.Add(Dir + d.ToString() + "\\"); //listBox1中填加目录名

                    //leftMenu.Text += "<a href='" + Dir + d.ToString() + "\' onclick='return false'><img src='/admin/admin_images/fileicon.gif' width='40' border='0' />" + d.Name.ToString() + "</a>";

                }

                foreach (FileInfo f in Dir.GetFiles("*.jpg")) //查找文件
                {

                    listBox1.Items.Add(Dir + f.ToString()); //listBox1中填加文件名

                }

            }

            catch (Exception e)
            {
                throw e;
            }

        }

  • 相关阅读:
    MyStreamRequestHandlerr
    SocketFromServer
    MyQMainWindowDemo
    MyQThread
    Nginx安装与配置
    nginx软件优化
    MySQL优化实施方案
    tomcat优化方向
    Tomcat优化方案
    Nginx和Tomcat优化
  • 原文地址:https://www.cnblogs.com/cosiray/p/1552710.html
Copyright © 2011-2022 走看看