Geeks With Blogs
Annie Bougie August 2008 Entries
Recursive Search for a Single File
I recently had to write a routine to search for the location of a particular file in a directory tree. I could find lots of code to create an array of all the filenames in the tree, but I needed to just retrieve the location of the filename I was looking for. So, here's the code: public static string SearchForSingleFile(string path, string fileName) { string searchPath = Path.Combine(path, fileName); if (File.Exists(searchPath)) { return searchPath; } string foundFile = string.Empty; string[] dirs ......

Posted On Saturday, August 16, 2008 2:18 AM

Copyright © Annie Bougie | Powered by: