7 New methods to Enumerate Directory and Files in .NET 4.0

.NET 4.0 introduces 7 new methods to Enumerate directories and files. All these methods return Enumerable Collections (IEnumerable<T>), which perform better than arrays.

Here are the 7 new methods:

Directory.EnumerateDirectories - Returns an enumerable collection of directory names in a specified path

DirectoryInfo.EnumerateDirectories - Returns an enumerable collection of directory information in the current directory

Directory.EnumerateFiles - Returns an enumerable collection of file names in a specified path

DirectoryInfo.EnumerateFiles - Returns an enumerable collection of file information in the current directory

Directory.EnumerateFileSystemEntries - Returns an enumerable collection of file-system entries in a specified path

DirectoryInfo.EnumerateFileSystemInfos - Returns an enumerable collection of file system information in the current directory

File.ReadLines - Reads the lines of a file

In my upcoming posts, I will show you how to use these new methods.



Will you give this article a +1 ? Thanks in advance


About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

1 comment:

Anonymous said...

Hi,

Is there any method that returns list of files from a directory for a given date range (i.e. start date - end date)