Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recursive method
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Recursive method
Miscellaneous
Thread ID:
00953166
Message ID:
00953166
Views:
49
I have created a find a file class and I have added the method below that calls itself (recursively). It goes through all sub folders from a given starting folder and adds a specified file to a collection of the class with the path. Now this should be pretty fimple but it doesn't work if the starting point is C:/ unless i add the messagebox when the file is found. If I comment out the messagebox call the application just hangs.
Because it works with the messagebox I know that the stack limit is not reached. Any input or ideas would be great.

Thanks,
Einar
public void SearchForFile (System.String sPath)
{
  System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(sPath);
  System.IO.FileSystemInfo[] dirs = di.GetDirectories();
			
  // check if the file is in the passed folder
  if (System.IO.File.Exists(sPath + "\\" + this.FileName))
  {
    this.FileCollection.Add(sPath + "\\" + this.FileName);
    System.Windows.Forms.MessageBox.Show("found a file");
  }
			
  foreach (System.IO.DirectoryInfo diNext in dirs) 
  {
    this.SearchForFile(diNext.FullName.ToString());
  }	
}
Semper ubi sub ubi.
Next
Reply
Map
View

Click here to load this message in the networking platform