学习 c#程序显示所选目录及其子目录内所有文件 - acefly的专栏 - CSDNBlog

来源:百度文库 编辑:神马文学网 时间:2024/04/29 02:09:37
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Collections;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace formTest
{
    public partial class Form3 : Form
    {
        SCItemSet itemSet = new SCItemSet();
        public Form3()
        {
            InitializeComponent();
        }
        ///
        /// 应用程序的主入口点。
        ///

        [STAThread]
        static void Main()
        {
            Application.Run(new Form3());
        }
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog browse = new FolderBrowserDialog();
            browse.ShowDialog();           
            txtShowPath.Text = browse.SelectedPath;
        }
        private void detail_Click(object sender, EventArgs e)
        {
            txtShowDetail.Text = string.Empty;
            string ShowInfo="";
            //string ShowPath = txtShowPath.Text.ToString().Replace("\\", @"\");
            getDirFiles(txtShowPath.Text);
            for(int i=0;i            {
                ShowInfo += itemSet[i].Name+"\r\n";
            }
            txtShowDetail.Text = ShowInfo.ToString(); 
        }
        public void getDirFiles(string strPaths)
        {
            DirectoryInfo d = new DirectoryInfo(strPaths);
           
            DirectoryInfo[] dis = d.GetDirectories();
            FileInfo[] fis = d.GetFiles();
            foreach (FileInfo fi in fis)
            {
                SCItem item = new SCItem();
                item.Name = fi.Name;
                itemSet.Add(item);
            }
            string strPath;
            foreach (DirectoryInfo di in dis)
            {  
                strPath=strPaths+"\\"+di.Name;
                getDirFiles(strPath);
            }
           
        }    }   
学习 c#程序显示所选目录及其子目录内所有文件 - acefly的专栏 - CSDNBlog 学习 c#程序显示所选目录及其子目录内所有文件 c#程序显示所选目录及其子目录内所有文件 c# static的全部用法 - acefly的专栏 - CSDNBlog Asp.net程序性能优化的七个方面 - acefly的专栏 - CSDNBlog 使用程序自动调用ANSYS并运行命令流文件 - 王学福的专栏 - CSDNBlog 傅立叶级数显示 - dirtysalt的专栏 - CSDNBlog J2EE 学习 - fanqinghai的专栏 - CSDNBlog DWR学习(一) - ceun的专栏 - CSDNBlog Window Mobile视频会议程序的开发 - enginetanmary的专栏 - CSDNBlog Window Mobile视频会议程序的开发 - enginetanmary的专栏 - CSDNBlog 关于搜索引擎及其开发 - xwjbs的专栏 - CSDNBlog vc中常用文件操作 - cxin917的专栏 - CSDNBlog vc中常用文件操作(转载) - yfwei的专栏 - CSDNBlog 用C# 实现C/S模式下软件自动在线升级 - wzq6511的专栏 - CSDNBlog 学习Java的30个基本概念 - 刀目村的专栏 - CSDNBlog C#编写程序的课程学习 - 51CTO.COM 常用搜索引擎列表 - 来自Ministone的学习、研究专栏! - CSDNBlog Java学习总论(转) - popkiler的专栏 - CSDNBlog 常用搜索引擎列表 - 来自Ministone的学习、研究专栏! - CSDNBlog Linux Socket学习(五) - mylxiaoyi的专栏 - CSDNBlog Linux操作系统的源代码目录树结构图解 - 软体疯子专栏 - CSDNBlog 典型的flex程序的编写步骤 - Booo.Lee 的专栏 - CSDNBlog QQ所有文件和目录的作用解释和分析