The DirectoryInfo().GetFiles() allows to negotiate with one filtering at a time. So, we usually have to do this to include several filters:
loDirectoryInfo = New DirectoryInfo(cDirectory)
For lnCounter = 1 To oApp.ParmCnt(cFilter)
Try
loFiles = loDirectoryInfo.GetFiles(oApp.GetParm(cFilter, lnCounter))
For Each loFile In loFiles
loRow = oDataSet.Tables(0).NewRow
So, basically, if I have three filters, the main For/Next loop will be executed three times, and for each loop, I am adding all the files found into a dataset row. From that point, it is up to everyone to decide of his own technique to store the found files. In my example, I use a dataset.
But, the question is about sub filtering. Say, I want to include *.TXT, *.PDF and *.JPG. This is no problem and it works very well. Lets assume 25 files are found. Then, I need to avoid negotiating with a file that will match a sub filter such as Store*.txt. So, we grab initially *.txt. But, if I collect 10 of those files and one is a match to Store*.txt, such as Store56.txt, that one need to be excluded.
To handle that, I started to build my own code in the second For/Next loop to avoid adding the row into the dataset if there is an exclusion that we have to consider. But, this is somewhat complicated to build. There are a lot of possibilities. We can have something like that to exclude: Store*.txt, *Something*.txt, MyFile*Something*.txt, etc.
So, is there a way to benefit from a related .NET object to initialize the file name I am presently negotating with in the second For/Next loop and avoid adding that row into mydataset if it matches the sub filter, thus the exclusion?