zoukankan      html  css  js  c++  java
  • 使用递归列出文件夹目录及目录下的文件

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;

    namespace 使用递归列出文件夹目录及目录下的文件
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void Form1_Load(object sender, EventArgs e)
            {
                string path = "D:\Notes";
                TreeNode node = treeView1.Nodes.Add(path);
                DirectoryToTree(path, node.Nodes);
            }

            private void DirectoryToTree(string path, TreeNodeCollection nodes)
            {
                foreach (string item in Directory.GetDirectories(path))
                {
                    TreeNode node = nodes.Add(Path.GetFileName(item));
                    DirectoryToTree(item, node.Nodes);

                }
                string[] strFiles = Directory.GetFiles(path);
                foreach (string str in strFiles)
                {
                    nodes.Add(Path.GetFileName(str));
                }
            }
        }
    }

    image

  • 相关阅读:
    MJRefreshFooterView
    UIActionSheet
    UIAlertView带textField
    SIAlertView
    旋转 锚点
    centos7.2 Apache+PHP7.2+Mysql5.6环境搭建
    ubuntu16.04 mysql 开启远程连接
    Ubuntu16.04重新安装MySQL数据库
    Ubuntu16.04彻底卸载MySQL
    laravel框架基础(2)---laravel项目加载机制
  • 原文地址:https://www.cnblogs.com/HarryChis/p/10460074.html
Copyright © 2011-2022 走看看