List All Files - CSharp File IO

CSharp examples for File IO:File Command

Description

List All Files

Demo Code


using System.Text.RegularExpressions;
using System.IO;// w ww .  jav a 2 s .  c  o  m
using System.Collections.Generic;
using System;

public class Main{
        private static void ListAllFiles(DirectoryInfo directoryInfo, List<FileInfo> list)
        {
            foreach(var subDirectory in directoryInfo.GetDirectories())
            {
                ListAllFiles(subDirectory, list);
            }

            foreach (var fileInfo in directoryInfo.GetFiles())
            {
                list.Add(fileInfo);
            }
        }
}

Related Tutorials