Returns an enumerable collection of file information in the current directory.
Assembly: mscorlib (in mscorlib.dll)
Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
This method pre-populates the values of the following FileInfo properties:
The returned collection is not cached; each call to the GetEnumerator method on the collection will start a new enumeration.
The following example enumerates the files under a specified directory and uses a LINQ query to return the names of all files that were created before 2009 by checking the value of the CreationTimeUtc property.
The following example shows how to enumerate files in a directory by using different search options. The example assumes a directory that has files named log1.txt, log2.txt, test1.txt, test2.txt, test3.txt, and a subdirectory that has a file named SubFile.txt.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.