I'm trying to write a LS agent to scan a directory in windows eg:'C:\' for any files and sub-directories. For each sub-directory, it will go inside and search for more files and sub-directories and continues until there's no more to look for. I'm used to write recursive code to replace or remove characters in a long string but for this one I'm totally lost. Below is my code (it's a mix of code from the domino help file and one I found in IBM site):
Sub Initialize
Dim pathname As String, filename As String
pathname = "C:\*.*"
filename = Dir(pathname, 16)
Print "Begin scan"
Do While filename<>""
If IsDir(pathname+filename)=True Then
Print pathname+filename+" is a directory"
'look for more directories and files in here
Else
Print filename+" is a file"
End If
filename=Dir()
Loop
Print "Finish scan"
End Sub
Function IsDir(Path As String) As Integer
Dim Void&
Dim Result As Boolean
On Error GoTo ErrorHandler
Void=FileLen(Path)
Result=False
GoTo Over
ErrorHandler:
Result=True
Resume Over
Over:
IsDir=Result
End Function
What do I need to change to make the code recursive at the commented part? ('look for more directories and files in here). I'm not just trying to find a specific file or directory. I want all that's available withing one. If I'm able to do that, then I can retrieve them and save into a NotesDocument.