Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filtering on directory files
Message
From
09/04/2011 15:27:06
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
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:
01506799
Views:
37
>Played with a couple of ideas not using the inbuilt filtering. Maybe overkill but potentially more flexible:
Dim filters As New List(Of String)() From { _
>	".CER", _
>	".TXT", _
>	".ZIP" _
>}
>Dim exclusions As New List(Of String)() From { _
>	"PG.010.cer", _
>	"canon1120.zip" _
>}
>Dim files As New List(Of FileInfo)()
>Dim di As New DirectoryInfo("C:\")
>' Get inclusions:
>For Each s As String In filters
>	files.AddRange(di.GetFiles().Where(Function(x) x.Extension.ToUpper() = s).ToList())
>Next
>'OR:
>files = di.GetFiles().ToList().FindAll(Function(fi As FileInfo) filters.Contains(fi.Extension.ToUpper()))
>' Remove exclusions:
>files = files.FindAll(Function(fi As FileInfo) Not exclusions.Contains(fi.Name))
Converted from C# and untested.....

It is an interesting approach. Thanks
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
Previous
Reply
Map
View

Click here to load this message in the networking platform