zoukankan      html  css  js  c++  java
  • 遍历路径下的所有文件

    1、先挂最顶级节点

     TreeListNode pNode = tlFileDisplay.AppendNode(new object[] { beOpen.Text }, -1);
     GetAllDirectory(beOpen.Text, tlFileDisplay, pNode);
    函数:

             /// <summary>
            /// 遍历文件夹
            /// </summary>
            /// <param name="sPath">当前路径</param>
            /// <param name="tlList">树结构</param>
            /// <param name="pNodeParent">父节点</param>
            private void GetAllDirectory(string sPath,TreeList tlList,TreeListNode pNodeParent)
            {
                string[] sDirectory = Directory.GetDirectories(sPath);
                foreach (string sDirPath in sDirectory)
                {
                    TreeListNode pNode = tlFileDisplay.AppendNode(new object[] { sDirPath }, pNodeParent);
                    GetAllFiles(sDirPath, tlList, pNode);
                    GetAllDirectory(sDirPath, tlList, pNode);
                }
            }
    
            /// <summary>
            /// 遍历文件
            /// </summary>
            /// <param name="sPath">路径</param>
            /// <param name="TreeList">树结构</param>
            /// <param name="ParentNode">父节点</param>
            private void GetAllFiles(string sPath, TreeList TreeList, TreeListNode ParentNode)
            {
                string[] sFiles = Directory.GetFiles(sPath);
                foreach (string sFileName in sFiles)
                {
                    TreeList.AppendNode(new object[] { sFileName }, ParentNode);
                }
            }



  • 相关阅读:
    Bugly和dispatch_once Crash
    IQKeyboardManager
    Storyboard References
    Book
    Git管理
    iOS开发之RunLoop--转
    H264之PPS、SPS了解
    iOS之UI设置随记
    使用 github 本地项目上传到github上 步骤
    spring中自定义注解
  • 原文地址:https://www.cnblogs.com/dengshiwei/p/4258689.html
Copyright © 2011-2022 走看看