DirectoryInfo.EnumerateFileSystemInfos 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回当前目录中的文件系统信息的可枚举集合。
重载
EnumerateFileSystemInfos(String, SearchOption) |
返回与指定的搜索模式和搜索子目录选项匹配的文件系统信息的可枚举集合。 |
EnumerateFileSystemInfos() |
返回当前目录中的文件系统信息的可枚举集合。 |
EnumerateFileSystemInfos(String) |
返回与指定的搜索模式匹配的文件系统信息的可枚举集合。 |
EnumerateFileSystemInfos(String, EnumerationOptions) |
返回与指定的搜索模式和枚举选项匹配的文件系统信息的可枚举集合。 |
EnumerateFileSystemInfos(String, SearchOption)
返回与指定的搜索模式和搜索子目录选项匹配的文件系统信息的可枚举集合。
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)
参数
- searchPattern
- String
要与目录名匹配的搜索字符串。 此参数可以包含有效文本路径和通配符(* 和 ?)的组合,但不支持正则表达式。
- searchOption
- SearchOption
用于指定搜索操作是应仅包含当前目录还是应包含所有子目录的枚举值之一。 默认值是 TopDirectoryOnly。
返回
与 searchPattern
和 searchOption
匹配的文件系统信息对象的可枚举集合。
例外
searchPattern
为 null
。
searchOption
不是有效的 SearchOption 值。
封装在 DirectoryInfo 对象中的路径无效(例如,它位于未映射的驱动器上)。
调用方没有所要求的权限。
注解
searchPattern
可以是文本字符和通配符的组合,但它不支持正则表达式。 中允许以下通配符说明符 searchPattern
。
通配符说明器 | 匹配 |
---|---|
* (星号) | 该位置中的零个或多个字符。 |
? (问号) | 该位置中的零个或一个字符。 |
通配符外的字符是文本字符。 例如,字符串 * "t"搜索以字母"t"结尾的所有名称。 ". 字符串 searchPattern
* "s"搜索以字母 path
"s"开头的所有名称。
和 EnumerateFileSystemInfos GetFileSystemInfos 方法不同,如下所示:
使用 时 EnumerateFileSystemInfos ,可以在返回整个集合 FileSystemInfo 之前开始枚举 对象的集合。
使用 时 GetFileSystemInfos ,必须等待返回整个 对象数组 FileSystemInfo ,然后才能访问数组。
因此,当你使用许多文件和目录时, EnumerateFileSystemInfos 可能更高效。
此方法预先填充以下属性的值 FileSystemInfo :
不缓存返回的集合;每次对 GetEnumerator 集合上的 方法的调用都将启动一个新的 枚举。
另请参阅
适用于
EnumerateFileSystemInfos()
返回当前目录中的文件系统信息的可枚举集合。
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)
返回
当前目录中的文件系统信息的可枚举集合。
例外
封装在 DirectoryInfo 对象中的路径无效(例如,它位于未映射的驱动器上)。
调用方没有所要求的权限。
注解
EnumerateFileSystemInfos和 GetFileSystemInfos 方法的区别如下:
使用时 EnumerateFileSystemInfos ,你可以在 FileSystemInfo 返回整个集合之前开始枚举对象的集合。
使用时 GetFileSystemInfos ,必须等待返回整个对象数组,然后才能 FileSystemInfo 访问数组。
因此,在处理多个文件和目录时, EnumerateFileSystemInfos 可能更高效。
此方法预先填充以下属性的值 FileSystemInfo :
未缓存返回的集合;对集合中的方法的每个调用 GetEnumerator 都将开始一个新的枚举。
另请参阅
适用于
EnumerateFileSystemInfos(String)
返回与指定的搜索模式匹配的文件系统信息的可枚举集合。
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)
参数
- searchPattern
- String
要与目录名匹配的搜索字符串。 此参数可以包含有效文本路径和通配符(* 和 ?)的组合,但不支持正则表达式。
返回
与 searchPattern
匹配的文件系统信息对象的可枚举集合。
例外
searchPattern
为 null
。
封装在 DirectoryInfo 对象中的路径无效(例如,它位于未映射的驱动器上)。
调用方没有所要求的权限。
注解
searchPattern
可以是文字和通配符的组合,但不支持正则表达式。 中允许使用以下通配符说明符 searchPattern
。
通配符说明符 | 匹配 |
---|---|
* (星号) | 此位置中的零个或多个字符。 |
? (问号) | 此位置中的零个或一个字符。 |
通配符以外的字符为原义字符。 例如,字符串 " * t" 搜索以字母 "t" 结尾的所有名称。 ". searchPattern
字符串 "s * " 搜索以 path
字母 "s" 开头的所有名称。
EnumerateFileSystemInfos和 GetFileSystemInfos 方法的区别如下:
使用时 EnumerateFileSystemInfos ,你可以在 FileSystemInfo 返回整个集合之前开始枚举对象的集合。
使用时 GetFileSystemInfos ,必须等待返回整个对象数组,然后才能 FileSystemInfo 访问数组。
因此,在处理多个文件和目录时, EnumerateFileSystemInfos 可能更高效。
此方法预先填充以下属性的值 FileSystemInfo :
未缓存返回的集合;对集合中的方法的每个调用 GetEnumerator 都将开始一个新的枚举。
另请参阅
适用于
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>
Public Function EnumerateFileSystemInfos (searchPattern As String, enumerationOptions As EnumerationOptions) As IEnumerable(Of FileSystemInfo)
参数
- searchPattern
- String
要与目录名匹配的搜索字符串。 此参数可以包含有效文本路径和通配符(* 和 ?)的组合,但不支持正则表达式。
- enumerationOptions
- EnumerationOptions
描述要使用的搜索和枚举配置的对象。
返回
与 searchPattern
和 enumerationOptions
匹配的文件系统信息对象的可枚举集合。
例外
searchPattern
为 null
。
封装在 DirectoryInfo 对象中的路径无效(例如,它位于未映射的驱动器上)。
调用方没有所要求的权限。
注解
searchPattern
可以是文字和通配符的组合,但不支持正则表达式。 中允许使用以下通配符说明符 searchPattern
。
通配符说明符 | 匹配 |
---|---|
* (星号) | 此位置中的零个或多个字符。 |
? (问号) | 此位置中的零个或一个字符。 |
通配符以外的字符为原义字符。 例如,字符串 " * t" 搜索以字母 "t" 结尾的所有名称。 ". searchPattern
字符串 "s * " 搜索以 path
字母 "s" 开头的所有名称。
EnumerateFileSystemInfos和 GetFileSystemInfos 方法的区别如下:
使用时 EnumerateFileSystemInfos ,你可以在 FileSystemInfo 返回整个集合之前开始枚举对象的集合。
使用时 GetFileSystemInfos ,必须等待返回整个对象数组,然后才能 FileSystemInfo 访问数组。
因此,在处理多个文件和目录时, EnumerateFileSystemInfos 可能更高效。
此方法预先填充以下属性的值 FileSystemInfo :
未缓存返回的集合;对集合中的方法的每个调用 GetEnumerator 都将开始一个新的枚举。