Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Filtering on directory files
Message
De
09/04/2011 15:27:06
 
 
À
09/04/2011 04:53:28
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01506723
Message ID:
01506799
Vues:
38
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform