C# 獲取某目錄下的全部文件

using System;
using System.Collections.Generic;
using System.IO;

private List<string> finded_files = new List<string>();
private void RecursiveGetFiles(string parent_path)
{
    string[] files = Directory.GetFiles(parent_path);
    foreach (string file in files)
    {
        // 這裏能夠進行文件的過濾,好比篩選指定的後綴
        finded_files.Add(file);
    }
    string[] paths = Directory.GetDirectories(parent_path);
    foreach (string path in paths)
    {
        RecursiveGetFiles(path);
    }
}
相關文章
相關標籤/搜索