DirectoryInfo.EnumerateFileSystemInfos DirectoryInfo.EnumerateFileSystemInfos DirectoryInfo.EnumerateFileSystemInfos DirectoryInfo.EnumerateFileSystemInfos Method

Definition

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

Overloads

EnumerateFileSystemInfos(String, SearchOption) EnumerateFileSystemInfos(String, SearchOption) EnumerateFileSystemInfos(String, SearchOption)

Returns an enumerable collection of file system information that matches a specified search pattern and search subdirectory option.

EnumerateFileSystemInfos() EnumerateFileSystemInfos() EnumerateFileSystemInfos() EnumerateFileSystemInfos()

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

EnumerateFileSystemInfos(String) EnumerateFileSystemInfos(String) EnumerateFileSystemInfos(String) EnumerateFileSystemInfos(String)

Returns an enumerable collection of file system information that matches a specified search pattern.

EnumerateFileSystemInfos(String, EnumerationOptions) EnumerateFileSystemInfos(String, EnumerationOptions) EnumerateFileSystemInfos(String, EnumerationOptions)

EnumerateFileSystemInfos(String, SearchOption) EnumerateFileSystemInfos(String, SearchOption) EnumerateFileSystemInfos(String, SearchOption)

Returns an enumerable collection of file system information that matches a specified search pattern and search subdirectory option.

public:
 System::Collections::Generic::IEnumerable<System::IO::FileSystemInfo ^> ^ EnumerateFileSystemInfos(System::String ^ searchPattern, System::IO::SearchOption searchOption);
public System.Collections.Generic.IEnumerable<System.IO.FileSystemInfo> EnumerateFileSystemInfos (string searchPattern, System.IO.SearchOption searchOption);
member this.EnumerateFileSystemInfos : string * System.IO.SearchOption -> seq<System.IO.FileSystemInfo>
Parameters
searchPattern
String String String String

The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions.

searchOption
SearchOption SearchOption SearchOption 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.

Returns

An enumerable collection of file system information objects that matches searchPattern and searchOption.

Exceptions

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

The caller does not have the required permission.

Remarks

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

Wildcard specifier Matches
* (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".

The EnumerateFileSystemInfos and GetFileSystemInfos methods differ as follows:

Therefore, when you are working with many files and directories, EnumerateFileSystemInfos can be more efficient.

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

The returned collection is not cached; each call to the GetEnumerator method on the collection will start a new enumeration.

See Also

EnumerateFileSystemInfos() EnumerateFileSystemInfos() EnumerateFileSystemInfos() EnumerateFileSystemInfos()

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

public:
 System::Collections::Generic::IEnumerable<System::IO::FileSystemInfo ^> ^ EnumerateFileSystemInfos();
public System.Collections.Generic.IEnumerable<System.IO.FileSystemInfo> EnumerateFileSystemInfos ();
member this.EnumerateFileSystemInfos : unit -> seq<System.IO.FileSystemInfo>
Public Function EnumerateFileSystemInfos () As IEnumerable(Of FileSystemInfo)
Returns

An enumerable collection of file system information in the current directory.

Exceptions

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

The caller does not have the required permission.

Remarks

The EnumerateFileSystemInfos and GetFileSystemInfos methods differ as follows:

Therefore, when you are working with many files and directories, EnumerateFileSystemInfos can be more efficient.

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

The returned collection is not cached; each call to the GetEnumerator method on the collection will start a new enumeration.

See Also

EnumerateFileSystemInfos(String) EnumerateFileSystemInfos(String) EnumerateFileSystemInfos(String) EnumerateFileSystemInfos(String)

Returns an enumerable collection of file system information that matches a specified search pattern.

public:
 System::Collections::Generic::IEnumerable<System::IO::FileSystemInfo ^> ^ EnumerateFileSystemInfos(System::String ^ searchPattern);
public System.Collections.Generic.IEnumerable<System.IO.FileSystemInfo> EnumerateFileSystemInfos (string searchPattern);
member this.EnumerateFileSystemInfos : string -> seq<System.IO.FileSystemInfo>
Public Function EnumerateFileSystemInfos (searchPattern As String) As IEnumerable(Of FileSystemInfo)
Parameters
searchPattern
String String String String

The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions.

Returns

An enumerable collection of file system information objects that matches searchPattern.

Exceptions

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

The caller does not have the required permission.

Remarks

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

Wildcard specifier Matches
* (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".

The EnumerateFileSystemInfos and GetFileSystemInfos methods differ as follows:

Therefore, when you are working with many files and directories, EnumerateFileSystemInfos can be more efficient.

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

The returned collection is not cached; each call to the GetEnumerator method on the collection will start a new enumeration.

See Also

EnumerateFileSystemInfos(String, EnumerationOptions) EnumerateFileSystemInfos(String, EnumerationOptions) EnumerateFileSystemInfos(String, EnumerationOptions)

public:
 System::Collections::Generic::IEnumerable<System::IO::FileSystemInfo ^> ^ EnumerateFileSystemInfos(System::String ^ searchPattern, System::IO::EnumerationOptions ^ enumerationOptions);
public System.Collections.Generic.IEnumerable<System.IO.FileSystemInfo> EnumerateFileSystemInfos (string searchPattern, System.IO.EnumerationOptions enumerationOptions);
member this.EnumerateFileSystemInfos : string * System.IO.EnumerationOptions -> seq<System.IO.FileSystemInfo>
Parameters
searchPattern
String String String String
Returns

Applies to