zoukankan      html  css  js  c++  java
  • 遍历一个文件夹下的所有文件

    一个老问题,但是总有人爱问,遍历一个文件夹下的所有文件,并输出文件信息。

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO;
    
    namespace IOTest
    {
        public partial class Form1 : Form
        {
        
            private FolderBrowserDialog fbd;
            public Form1()
            {
                fbd = new FolderBrowserDialog();
                InitializeComponent();
            }
    
            private void btnOpen_Click(object sender, EventArgs e)
            {
                //选择路径
                fbd.ShowDialog();
                this.richTextBox1.Text ="open:"+ fbd.SelectedPath;
                //输出文件名
                PutOutName(fbd.SelectedPath);
            }
    
            private void PutOutName(string path)
            {
                foreach (string subPath in Directory.GetDirectories(path))
                {
                    PutOutName(subPath);
                }
    DirectoryInfo dir
    = new DirectoryInfo(path); foreach (FileInfo file in dir.GetFiles()) { this.richTextBox1.AppendText(" "+file.FullName+" size:"+file.Length.ToString()+" createTime:"+file.CreationTime.ToString()); } } } }
  • 相关阅读:
    Exp7 网络欺诈防范
    Exp6 信息搜集与漏洞扫描
    Exp4 恶意代码分析
    Exp2 后门原理与实践
    PC平台逆向破解实验报告
    See You Again——我最后的汇编程序
    表格标签
    ansible环境搭建
    OSPF_1
    Linux的文件管理(8-27)
  • 原文地址:https://www.cnblogs.com/longling2344/p/5769133.html
Copyright © 2011-2022 走看看