Im implementing a file search in vb.net using a recursive algorithm, for each of the directories in a directory it itterates calling itself, then checks the files in the directory.
My problem is that its jumping back out of the recursion before it reaches the end of the directory tree, so my current thinking is maybe the call stack is full of the recursive method calls?
The program doesnt give any errors, or break, and carries on as if everything was working fine. If i take out the recursiveness it lists all the directories correctly, so it is deffinatly able to read them all.
Any ideas how to sort this?
This is the code I am using :-
Sub DirSearch(ByVal sDir As String)
Dim d As String
Dim f As String
Try
For Each d In Directory.GetDirectories(sDir)
DirSearch(d)
For Each f In Directory.GetFiles(d, "*")
Check_Files(f)
Next
RaiseEvent CurrentDir(d)
Next
Catch excpt As System.Exception
Debug.WriteLine(excpt.Message)
End Try
End Sub
My problem is that its jumping back out of the recursion before it reaches the end of the directory tree, so my current thinking is maybe the call stack is full of the recursive method calls?
The program doesnt give any errors, or break, and carries on as if everything was working fine. If i take out the recursiveness it lists all the directories correctly, so it is deffinatly able to read them all.
Any ideas how to sort this?
This is the code I am using :-
Sub DirSearch(ByVal sDir As String)
Dim d As String
Dim f As String
Try
For Each d In Directory.GetDirectories(sDir)
DirSearch(d)
For Each f In Directory.GetFiles(d, "*")
Check_Files(f)
Next
RaiseEvent CurrentDir(d)
Next
Catch excpt As System.Exception
Debug.WriteLine(excpt.Message)
End Try
End Sub