I try to use the dir command in a background agentto see all files in a directory. I never see anything:
Here is my code:
Sub importDocs(folderName As String)
On Error Goto Errorhandler
'Searching database for new docs or updates
Print "$Import =>> Searching folder " + folderName
Dim tmpFileName As String
Dim fileName() As String
Dim i As Integer
Dim j As Integer
Dim file As String
tmpFileName = Dir$(folderName,0)
i = 0
'Alle fileNamen in Liste einlesen
Do While tmpFileName <> ""
Redim Preserve fileName(i)
fileName(i) = tmpFileName
Print tmpFileName
i = i + 1
tmpFileName = Dir
Loop
'über alle files in Liste loopen
j = 0
Do While j < i
file = folderName + fileName(j)
'Keine Directories importieren, werden im else case behandelt
If Getfileattr(file) < 16 Or (Getfileattr(file) >= 32 And Getfileattr(file) < 54) Then
'Neue Dokumente erstellen
Call createDocument(file)
'files aus directory löschen
'Kill file
'Falls SubFolder, funkrion rekursiv aufrufen
Elseif (Getfileattr(file) >= 16 And Getfileattr(file) < 32) Then
'in windows immer diese zwei files auslassen
If fileName(j) <> "." And fileName(j) <> ".." Then
'rekursiver aufruf
Call importDocs(file + "\")
End If
End If
nextFile:
'Step in here after Error
j = j + 1
Loop
ExitSub:
Exit Sub
Errorhandler:
Print "Error in $Import =>> " + Error() + " : " + file + "; File Attribut: " + Cstr(Getfileattr(file))
Resume nextFile
End Sub
is this an iSeries problem or is something in my code wrong?
Thanks in advance
Tonio