System.IO.DirectoryInfo.GetFileSystemInfos Method

Retrieves an array of System.IO.FileSystemInfo objects that represent the files and subdirectories matching the specified search criteria.

Syntax

public FileSystemInfo[] GetFileSystemInfos (string searchPattern, SearchOption searchOption)

Parameters

searchPattern
The search string to match against the names of directories and filesa. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
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 SearchOption.TopDirectoryOnly.

Returns

An array of file system entries that match the search criteria.

Remarks

searchPattern can be a combination of literal and wildcard characters, but doesn't support regular expressions. The following wildcard specifiers are permitted in searchPattern.

* (asterisk)

Zero or more characters in that position.

? (question mark)

Zero or one character in that position.

Characters other than the wildcard are literal characters. For example, the string "*t" searches for all names in ending with the letter "t". ". The searchPattern string "s*" searches for all names in path beginning with the letter "s".

For subdirectories, the System.IO.FileSystemInfo objects returned by this method can be cast to the derived class System.IO.DirectoryInfo. Use the System.IO.FileAttributes value returned by the FileSystemInfo.Attributes property to determine whether the System.IO.FileSystemInfo represents a file or a directory.

This method pre-populates the values of the following System.IO.FileSystemInfo properties:

Requirements

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