资源简介

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)
        {
            this.listBox1.Items.Add(rtxtResult.Text);
            for (int i = 0; i < listBox1.Items.Count; i++)
            {


                DirectoryInfo TheFolder = new DirectoryInfo(listBox1.Items[i].ToString());

                try
                {
                    foreach (DirectoryInfo NextFolder in TheFolder.G

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-04-22 18:50  WindowsFormsApplication7\
     目录           0  2018-04-22 18:50  WindowsFormsApplication7\WindowsFormsApplication7\
     文件         962  2018-04-22 18:50  WindowsFormsApplication7\WindowsFormsApplication7.sln
     文件       33792  2018-04-23 10:47  WindowsFormsApplication7\WindowsFormsApplication7.v11.suo
     目录           0  2018-04-22 18:50  WindowsFormsApplication7\WindowsFormsApplication7\bin\
     目录           0  2018-04-23 11:47  WindowsFormsApplication7\WindowsFormsApplication7\bin\Debug\
     文件        1861  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.application
     文件        9728  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.exe
     文件        4136  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.exe.manifest
     文件       28160  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.pdb
     文件        1861  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.vshost.application
     文件       22472  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.vshost.exe
     文件        4136  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\bin\Debug\WindowsFormsApplication7.vshost.exe.manifest
     文件        2316  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\Form1.cs
     文件        4407  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\Form1.Designer.cs
     文件        5817  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\Form1.resx
     目录           0  2018-04-22 18:50  WindowsFormsApplication7\WindowsFormsApplication7\obj\
     目录           0  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\
     文件        1451  2018-04-22 18:55  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7125  2018-04-23 11:47  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2018-04-22 18:50  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\TempPE\
     文件        1861  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.application
     文件        1988  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.csproj.FileListAbsolute.txt
     文件         975  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.csproj.GenerateResource.Cache
     文件        2209  2018-04-22 18:51  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.csprojResolveAssemblyReference.cache
     文件        9728  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.exe
     文件        4136  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.exe.manifest
     文件         180  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.Form1.resources
     文件       28160  2018-04-23 11:53  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.pdb
     文件         180  2018-04-23 11:47  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.Properties.Resources.resources
     文件        1273  2018-04-23 11:47  WindowsFormsApplication7\WindowsFormsApplication7\obj\Debug\WindowsFormsApplication7.TrustInfo.xml
............此处省略9个文件信息

评论

共有 条评论