recursive directory search in c#
public void ExamineDir(string strDir){// Make sure we catch exceptions // in looking at this directory.try{// Loop through the list of directories.foreach (string strDirName in Directory.GetDirectories(strDir)){// Display the directory name.//Console.WriteLine(strDirName);string[] flist=Directory.GetFiles(strDirName);foreach(string fl in flist){//int ind=fl.LastIndexOf(@"\");if(fl.EndsWith(".aspx")fl.EndsWith(".aspx.cs")fl.EndsWith(".html")){++k;//Console.WriteLine(fl.Substring(ind+1)); Console.WriteLine(fl); }}// Call the ExamineDir method recursively // thereby traversing the directory// tree to any depth.ExamineDir(strDirName);}}catch{}}
Thursday, September 27, 2007
Subscribe to:
Comments (Atom)