• 大小: 0.08M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-02-23
  • 语言: C#
  • 标签: 文件夹  遍历  文件  C#  

资源简介

按指定层级遍历文件夹目录

资源截图

代码片段和文件信息

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

namespace TraverseFolder
{
    public partial class Form1 : Form
    {
        string savePath = null;
        int flag = 0;
        int flag2 = 0;
       
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = “请选择文件路径“;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                savePath = dialog.SelectedPath;
                txtName.Text = savePath;
                PaintTreeView(this.treeView1 savePath);
            } 

        }
        #region 生成程序所在根目录的TreeView
        priva

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-09-10 14:02  TraverseFolder\
     目录           0  2018-09-10 14:02  TraverseFolder\TraverseFolder\
     目录           0  2018-12-10 15:24  TraverseFolder\TraverseFolder\TraverseFolder\
     文件         187  2018-09-10 13:33  TraverseFolder\TraverseFolder\TraverseFolder\App.config
     文件        5549  2018-12-10 09:22  TraverseFolder\TraverseFolder\TraverseFolder\Form1.Designer.cs
     文件        7521  2018-12-10 15:24  TraverseFolder\TraverseFolder\TraverseFolder\Form1.cs
     文件        6015  2018-12-10 14:13  TraverseFolder\TraverseFolder\TraverseFolder\Form1.resx
     文件         526  2018-09-10 09:37  TraverseFolder\TraverseFolder\TraverseFolder\Program.cs
     目录           0  2019-04-12 08:28  TraverseFolder\TraverseFolder\TraverseFolder\Properties\
     文件        1370  2018-09-10 09:37  TraverseFolder\TraverseFolder\TraverseFolder\Properties\AssemblyInfo.cs
     文件        2880  2018-09-10 09:37  TraverseFolder\TraverseFolder\TraverseFolder\Properties\Resources.Designer.cs
     文件        5612  2018-09-10 09:37  TraverseFolder\TraverseFolder\TraverseFolder\Properties\Resources.resx
     文件        1101  2018-09-10 09:37  TraverseFolder\TraverseFolder\TraverseFolder\Properties\Settings.Designer.cs
     文件         249  2018-09-10 09:37  TraverseFolder\TraverseFolder\TraverseFolder\Properties\Settings.settings
     文件         257  2019-04-12 08:28  TraverseFolder\TraverseFolder\TraverseFolder\Properties\licenses.licx
     文件        4642  2018-09-10 09:51  TraverseFolder\TraverseFolder\TraverseFolder\TraverseFolder.csproj
     目录           0  2018-09-10 14:02  TraverseFolder\TraverseFolder\TraverseFolder\bin\
     目录           0  2018-09-10 14:02  TraverseFolder\TraverseFolder\TraverseFolder\bin\Debug\
     文件       12800  2019-04-12 08:28  TraverseFolder\TraverseFolder\TraverseFolder\bin\Debug\TraverseFolder.exe
     文件         187  2018-09-10 13:33  TraverseFolder\TraverseFolder\TraverseFolder\bin\Debug\TraverseFolder.exe.config
     文件       30208  2019-04-12 08:28  TraverseFolder\TraverseFolder\TraverseFolder\bin\Debug\TraverseFolder.pdb
     文件       24224  2019-04-12 08:29  TraverseFolder\TraverseFolder\TraverseFolder\bin\Debug\TraverseFolder.vshost.exe
     文件         187  2018-09-10 13:33  TraverseFolder\TraverseFolder\TraverseFolder\bin\Debug\TraverseFolder.vshost.exe.config
     文件         490  2013-03-18 17:00  TraverseFolder\TraverseFolder\TraverseFolder\bin\Debug\TraverseFolder.vshost.exe.manifest
     目录           0  2018-09-10 14:02  TraverseFolder\TraverseFolder\TraverseFolder\obj\
     目录           0  2019-04-12 08:28  TraverseFolder\TraverseFolder\TraverseFolder\obj\Debug\
     文件       77477  2018-09-10 09:46  TraverseFolder\TraverseFolder\TraverseFolder\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7777  2018-09-10 14:21  TraverseFolder\TraverseFolder\TraverseFolder\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2020-06-17 09:01  TraverseFolder\TraverseFolder\TraverseFolder\obj\Debug\TempPE\
     文件           0  2018-09-10 09:37  TraverseFolder\TraverseFolder\TraverseFolder\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2018-09-10 09:37  TraverseFolder\TraverseFolder\TraverseFolder\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
............此处省略11个文件信息

评论

共有 条评论