File Search : Directory : File Stream C# Source Code


Custom Search

C# Source Code » File Stream » Directory »

 

File Search








    
 
using System;
using System.IO;
public class FileSearch {
    public static void Main() {
        String searchName = "win";
        DirectoryInfo myDir = new DirectoryInfo(@"c:\Program Files");
        SearchDirectories(myDir, searchName);
    }

    public static void SearchDirectories(DirectoryInfo dir, String target) {
        FileInfo[] files = dir.GetFiles();
        foreach (FileInfo file in files) {
            if (file.Name.IndexOf(target) > -1) {
                Console.WriteLine(file.Name);
            }
        }

        DirectoryInfo[] dirs = dir.GetDirectories();
        foreach (DirectoryInfo subDir in dirs) {
            SearchDirectories(subDir, target);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo File Stream
» Directory