Colleagues,
The subject line says it, and I'm at the end of the rope with frustration! This is what's happening:
I have a root dir, with subdirs, where I have files of type *.LOG, *.XML and *.PS;
These files can be located in the root dir or in a subdir, or both;
This Directory.GetFiles() method works when run as standalone, like this:
However, when I try it like this, in a Sub...
... it gives me only the files in subdir, but not the files in the root dir:
I've been struggling with this problem for 3 workdays already - and can't figure out why it works as standalone, but doesn't in a Sub...
What am I doing wrong?
Regards,
Ilya
The subject line says it, and I'm at the end of the rope with frustration! This is what's happening:
I have a root dir, with subdirs, where I have files of type *.LOG, *.XML and *.PS;
These files can be located in the root dir or in a subdir, or both;
This Directory.GetFiles() method works when run as standalone, like this:
However, when I try it like this, in a Sub...
Code:
'Dim lsRootDir As String = "C:\Temp", laRes(0) As String, lsExt As String = "*.XML, *.LOG, *.PS"
GetAllFiles(lsRootDir, lsExt, laRes)
End Sub
'====================================================================================================================================
====================================================================================================================================
Private Sub GetAllFiles(ByVal tsRootDir As String, ByVal tsExt As String, ByRef taRet() As String)
'====================================================================================================================================
Dim laExt() As String, I As Integer, liCnt As Integer, lcExt As String
laExt = tsExt.Split(CType(",", Char()), StringSplitOptions.RemoveEmptyEntries)
liCnt = laExt.Length - 1
For I = 0 To liCnt
lcExt = laExt(I)
Dim laRes() As String = Directory.GetFiles(tsRootDir, lcExt, SearchOption.AllDirectories)
If laRes.Length > 0 Then
taRet = taRet.Concat(laRes).ToArray()
End If
Next
End Sub
'====================================================================================================================================
... it gives me only the files in subdir, but not the files in the root dir:
I've been struggling with this problem for 3 workdays already - and can't figure out why it works as standalone, but doesn't in a Sub...
What am I doing wrong?
Regards,
Ilya