zoukankan      html  css  js  c++  java
  • C#遍历目录下的文件和子目录

     1         //打开目录
     2         private void BtnClickOpenDirPics(object sender, EventArgs e)
     3         {
     4             FolderBrowserDialog DirPics = new FolderBrowserDialog();
     5             DirPics.SelectedPath = "D:\";
     6 
     7             if (DirPics.ShowDialog() == DialogResult.OK)
     8             {
     9                 string FolderPathName = DirPics.SelectedPath;
    10                 DirectoryInfo DiFolder = new DirectoryInfo(FolderPathName);
    11                 ArrayList Lfiles = new ArrayList();
    12                 GetAll(DiFolder, ref Lfiles);
    14             }
    15         }
    16 
    17         private void GetAll(DirectoryInfo dir, ref ArrayList FileList)//搜索文件夹中的文件
    18         {
    19             FileInfo[] allFile = dir.GetFiles();
    20             foreach (FileInfo fi in allFile)
    21             {
    22                 FileList.Add(fi.FullName);
    23             }
    24 
    25             DirectoryInfo[] allDir = dir.GetDirectories();
    26             foreach (DirectoryInfo d in allDir)
    27             {
    28                 GetAll(d, ref FileList);
    29             }
    30         }
  • 相关阅读:
    NOI2018 退役记
    APIO2018 被屠记
    CTSC2018 被屠记
    SNOI2018 退役记
    O(1) long long a*b%p
    prufer编码
    杜教筛
    GCC卡常
    NOIP2017滚粗记
    UVA 10763 Foreign Exchange
  • 原文地址:https://www.cnblogs.com/autumoonchina/p/3566590.html
Copyright © 2011-2022 走看看