Directory Search - CSharp System.IO

CSharp examples for System.IO:DirectoryInfo

Description

Directory Search

Demo Code

// This program is free software; you can redistribute it and/or
using System.Diagnostics;
using System.Reflection;
using System.IO;//from w  ww .  j  a va 2 s  . c  o m
using System.Collections;
using System;

public class Main{
        private static void DirectorySearch(ArrayList matches, DirectoryInfo dirInfo, string assemblyName) {
            try {
                foreach (DirectoryInfo directory in dirInfo.GetDirectories()) {
                    foreach (FileInfo file in directory.GetFiles(assemblyName + "*")) {
                        matches.Add(file);
                    }
                    DirectorySearch(matches, directory, assemblyName);
                }
            }
            finally {
                // do nothing
            }
        }
}

Related Tutorials