Editare

Partajați prin


DirectoryInfo.EnumerateFileSystemInfos Method

Definition

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

Overloads

EnumerateFileSystemInfos(String, SearchOption)

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

EnumerateFileSystemInfos()

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

EnumerateFileSystemInfos(String)

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

EnumerateFileSystemInfos(String, EnumerationOptions)

Returns an enumerable collection of file system information that matches the specified search pattern and enumeration options.

EnumerateFileSystemInfos(String, SearchOption)

Source:
DirectoryInfo.cs
Source:
DirectoryInfo.cs
Source:
DirectoryInfo.cs

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>
Public Function EnumerateFileSystemInfos (searchPattern As String, searchOption As SearchOption) As IEnumerable(Of FileSystemInfo)

Parameters

searchPattern
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

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

searchPattern is null.

searchOption is not a valid SearchOption value.

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

Applies to

EnumerateFileSystemInfos()

Source:
DirectoryInfo.cs
Source:
DirectoryInfo.cs
Source:
DirectoryInfo.cs

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

Applies to

EnumerateFileSystemInfos(String)

Source:
DirectoryInfo.cs
Source:
DirectoryInfo.cs
Source:
DirectoryInfo.cs

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

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

searchPattern is null.

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

Applies to

EnumerateFileSystemInfos(String, EnumerationOptions)

Source:
DirectoryInfo.cs
Source:
DirectoryInfo.cs
Source:
DirectoryInfo.cs

Returns an enumerable collection of file system information that matches the specified search pattern and enumeration options.

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>
Public Function EnumerateFileSystemInfos (searchPattern As String, enumerationOptions As EnumerationOptions) As IEnumerable(Of FileSystemInfo)

Parameters

searchPattern
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.

enumerationOptions
EnumerationOptions

An object that describes the search and enumeration configuration to use.

Returns

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

Exceptions

searchPattern is null.

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.

Applies to