Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filtering on directory files
Message
From
08/04/2011 17:27:06
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Filtering on directory files
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01506723
Message ID:
01506723
Views:
96
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 each filtering
            For lnCounter = 1 To oApp.ParmCnt(cFilter)

                Try
                    loFiles = loDirectoryInfo.GetFiles(oApp.GetParm(cFilter, lnCounter))

                    ' Get all the files in the directory
                    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?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform