Export (0) Print
Expand All

DirectoryInfo.EnumerateFileSystemInfos Method (String, SearchOption)

When it is called by trusted applications, returns an enumerable collection of file system information that matches a specified search pattern and search subdirectory option.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

public IEnumerable<FileSystemInfo> EnumerateFileSystemInfos(
	string searchPattern,
	SearchOption searchOption
)

Parameters

searchPattern
Type: System.String
The search string. The default pattern is "*", which returns all files or directories.
searchOption
Type: System.IO.SearchOption
One of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories. The default value is TopDirectoryOnly.

Return Value

Type: System.Collections.Generic.IEnumerable<FileSystemInfo>
An enumerable collection of file system information objects that matches searchPattern and searchOption.

ExceptionCondition
ArgumentNullException

searchPattern is null.

ArgumentOutOfRangeException

searchOption is not a valid SearchOption value.

DirectoryNotFoundException

The path encapsulated in the FileSystemInfo object is invalid (for example, it is on an unmapped drive).

SecurityException

The caller does not have the required permission.

The following wildcard specifiers are permitted in the searchPattern parameter.

Wildcard character

Description

*

Zero or more characters.

?

Exactly one character.

Silverlight

Supported in: 5, 4

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft