// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; public class MainClass { public static string Find(string dir, String fnm) { string[] files = Directory.GetFiles(dir); foreach(string f in files) { if(Path.Combine(dir, fnm) == f) { return dir; } } string[] dirs = Directory.GetDirectories(dir); foreach(string d in dirs) { if(d != @"C:\System Volume Information") { string res = Find(d, fnm); if(res != null) { return res; } } } return null; } public static void Main(string[] args) { Console.WriteLine(Find(@"C:\", "dir.cs")); Console.WriteLine(Find(@"C:\", "dir2.cs")); } }