• 大小: 0.06M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2020-12-14
  • 语言: C#
  • 标签: C#  文件  遍历  目录  c  

资源简介

C#遍历指定目录下的所有文件夹名

资源截图

代码片段和文件信息

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 WindowsFormsApplication7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

      

        private void button2_Click(object sender EventArgs e)
        {
           



            DirectoryInfo TheFolder = new DirectoryInfo(rtxtResult.Text.ToString());

                try
                {
                    foreach (DirectoryInfo NextFolder in TheFolder.GetDirectories())
                    {
                        
                            listBox1.Items.Add(NextFol

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-04-22 18:50  WindowsFormsApplication7\
     文件         962  2018-04-22 18:50  WindowsFormsApplication7.sln
     文件       36352  2018-04-23 14:09  WindowsFormsApplication7.v11.suo
     目录           0  2018-04-22 18:50  WindowsFormsApplication7\bin\
     目录           0  2018-04-23 11:47  WindowsFormsApplication7\bin\Debug\
     文件        1861  2018-04-23 14:07  WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.application
     文件        9728  2018-04-23 14:07  WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.exe
     文件        4136  2018-04-23 14:07  WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.exe.manifest
     文件       26112  2018-04-23 14:07  WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.pdb
     文件        1861  2018-04-23 14:07  WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.vshost.application
     文件       22472  2018-04-23 14:09  WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.vshost.exe
     文件        4136  2018-04-23 14:07  WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.vshost.exe.manifest
     文件        1383  2018-04-23 14:07  WindowsFormsApplication7\Form1.cs
     文件        5451  2018-04-23 14:07  WindowsFormsApplication7\Form1.Designer.cs
     文件        5817  2018-04-23 14:07  WindowsFormsApplication7\Form1.resx
     目录           0  2018-04-22 18:50  WindowsFormsApplication7\obj\
     目录           0  2018-04-23 14:07  WindowsFormsApplication7\obj\Debug\
     文件        1451  2018-04-22 18:55  WindowsFormsApplication7\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7191  2018-04-23 12:37  WindowsFormsApplication7\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2018-04-22 18:50  WindowsFormsApplication7\obj\Debug\TempPE\
     文件        1861  2018-04-23 14:07  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.application
     文件        4184  2018-04-23 14:09  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.csproj.FileListAbsolute.txt
     文件         975  2018-04-23 14:07  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.csproj.GenerateResource.Cache
     文件        2209  2018-04-22 18:51  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.csprojResolveAssemblyReference.cache
     文件        9728  2018-04-23 14:07  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.exe
     文件        4136  2018-04-23 14:07  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.exe.manifest
     文件         180  2018-04-23 14:07  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.Form1.resources
     文件       26112  2018-04-23 14:07  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.pdb
     文件         180  2018-04-23 11:47  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.Properties.Resources.resources
     文件        1273  2018-04-23 11:47  WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.TrustInfo.xml
     文件         505  2018-04-22 18:50  WindowsFormsApplication7\Program.cs
............此处省略8个文件信息

评论

共有 条评论