![]() |
Languages »
VB.NET »
Utilities
Intermediate
License: The Code Project Open License (CPOL)
Enhanced version of vb.net GetFilesBy LeeBearThis is an inline enumeration of files instead of building an array first |
C#, VB (VB 7.x, VB 8.0, VB 9.0, VB 6), Windows (Win2K, WinXP, Win2003, Vista, TabletPC), .NET (.NET 2.0, .NET 3.0, .NET 3.5), Visual Studio (VS2005, VS2008), Dev
|
||||||||
|
Advanced Search |
|
|
|
||||||||||||||||
Part of my job requires batch processing large amounts of files, on the order of 100,000 to 1,000,000. Back in the VB6 days the code found each file in the directory. When upgrading to .Net the GetFiles method was implemented and performance TANKED. This is an implementation of the FindFirstFile, FindNextFile that can be called just like GetFiles with a bonus of returning all of the file attributes too.
There are other versions of this out there mostly in C# format using the yield return which is not a part of VB.Net at this time.
This implementation handles multiple wildcard matches, but only one source directory.
It would be easy to add an Enumerator class around the Files class to handle multiple directories, but I did not have need for that at this time.
This is just an class module and a help file to explain the class. You simply add the class to your project and implement it just like the Microsoft version of GetFiles.
For Each file As Files.WIN32_FIND_DATA In _
Files.GetFilesEx _
( _
"c:\", _
SYSTEM.FileIO.SearchOption.SearchAllSubDirectories, _
"*.txt,*.doc" _
)
Console.WriteLine(file.ToString)
Next
This example will find all the Text and Document files on the C: drive.
Unlike the .Net version of GetFiles, this version will look into any sub-directory and will not generate errors doing so.
Intial Release November 21, 2008
| You must Sign In to use this message board. | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 21 Nov 2008 Editor: |
Copyright 2008 by LeeBear Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |