DirectoryInfo.EnumerateFileSystemInfos 方法

定義

傳回目前目錄中檔案系統資訊的可列舉集合。Returns an enumerable collection of file system information in the current directory.

多載

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)

傳回符合指定之搜尋模式和搜尋子目錄選項的檔案系統資訊的可列舉集合。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>

參數

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. 預設值為 TopDirectoryOnlyThe default value is TopDirectoryOnly.

傳回

符合 searchPatternsearchOption 的檔案系統資訊的可列舉集合。An enumerable collection of file system information objects that matches searchPattern and searchOption.

例外狀況

searchPatternnullsearchPattern is null.

searchOption 不是有效的 SearchOption 值。searchOption is not a valid SearchOption value.

DirectoryInfo 物件中封裝的路徑無效 (例如它位於未對應的磁碟機上)。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.

備註

searchPattern 可以是常值和萬用字元的組合,但是不支援正則運算式。searchPattern can be a combination of literal and wildcard characters, but it doesn't support regular expressions. searchPattern中允許下列萬用字元規範。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. 例如,字串 "*t" 會搜尋結尾為字母 "t" 的所有名稱。For example, the string "*t" searches for all names in ending with the letter "t". ".". searchPattern 字串 "s*" 會搜尋 path 開頭為字母 "s" 的所有名稱。The searchPattern string "s*" searches for all names in path beginning with the letter "s".

EnumerateFileSystemInfosGetFileSystemInfos 方法的差異如下:The EnumerateFileSystemInfos and GetFileSystemInfos methods differ as follows:

因此,當您使用許多檔案和目錄時,EnumerateFileSystemInfos 可能會更有效率。Therefore, when you are working with many files and directories, EnumerateFileSystemInfos can be more efficient.

這個方法會預先填入下列 FileSystemInfo 屬性的值:This method pre-populates the values of the following FileSystemInfo properties:

傳回的集合不會進行快取;每次呼叫集合上的 GetEnumerator 方法都會啟動新的列舉。The returned collection is not cached; each call to the GetEnumerator method on the collection will start a new enumeration.

另請參閱

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)

傳回

目前目錄中檔案系統資訊的可列舉集合。An enumerable collection of file system information in the current directory.

例外狀況

DirectoryInfo 物件中封裝的路徑無效 (例如它位於未對應的磁碟機上)。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.

備註

EnumerateFileSystemInfosGetFileSystemInfos 方法的差異如下:The EnumerateFileSystemInfos and GetFileSystemInfos methods differ as follows:

因此,當您使用許多檔案和目錄時,EnumerateFileSystemInfos 可能會更有效率。Therefore, when you are working with many files and directories, EnumerateFileSystemInfos can be more efficient.

這個方法會預先填入下列 FileSystemInfo 屬性的值:This method pre-populates the values of the following FileSystemInfo properties:

傳回的集合不會進行快取;每次呼叫集合上的 GetEnumerator 方法都會啟動新的列舉。The returned collection is not cached; each call to the GetEnumerator method on the collection will start a new enumeration.

另請參閱

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)

參數

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.

傳回

符合 searchPattern 的檔案系統資訊的可列舉集合。An enumerable collection of file system information objects that matches searchPattern.

例外狀況

searchPatternnullsearchPattern is null.

DirectoryInfo 物件中封裝的路徑無效 (例如它位於未對應的磁碟機上)。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.

備註

searchPattern 可以是常值和萬用字元的組合,但是不支援正則運算式。searchPattern can be a combination of literal and wildcard characters, but it doesn't support regular expressions. searchPattern中允許下列萬用字元規範。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. 例如,字串 "*t" 會搜尋結尾為字母 "t" 的所有名稱。For example, the string "*t" searches for all names in ending with the letter "t". ".". searchPattern 字串 "s*" 會搜尋 path 開頭為字母 "s" 的所有名稱。The searchPattern string "s*" searches for all names in path beginning with the letter "s".

EnumerateFileSystemInfosGetFileSystemInfos 方法的差異如下:The EnumerateFileSystemInfos and GetFileSystemInfos methods differ as follows:

因此,當您使用許多檔案和目錄時,EnumerateFileSystemInfos 可能會更有效率。Therefore, when you are working with many files and directories, EnumerateFileSystemInfos can be more efficient.

這個方法會預先填入下列 FileSystemInfo 屬性的值:This method pre-populates the values of the following FileSystemInfo properties:

傳回的集合不會進行快取;每次呼叫集合上的 GetEnumerator 方法都會啟動新的列舉。The returned collection is not cached; each call to the GetEnumerator method on the collection will start a new enumeration.

另請參閱

EnumerateFileSystemInfos(String, EnumerationOptions)

傳回符合指定搜尋模式和列舉選項之檔案系統資訊的可列舉集合。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>

參數

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.

傳回

符合 searchPatternenumerationOptions 的檔案系統資訊的可列舉集合。An enumerable collection of file system information objects that matches searchPattern and enumerationOptions.

例外狀況

searchPatternnullsearchPattern is null.

DirectoryInfo 物件中封裝的路徑無效 (例如它位於未對應的磁碟機上)。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.

備註

searchPattern 可以是常值和萬用字元的組合,但是不支援正則運算式。searchPattern can be a combination of literal and wildcard characters, but it doesn't support regular expressions. searchPattern中允許下列萬用字元規範。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. 例如,字串 "*t" 會搜尋結尾為字母 "t" 的所有名稱。For example, the string "*t" searches for all names in ending with the letter "t". ".". searchPattern 字串 "s*" 會搜尋 path 開頭為字母 "s" 的所有名稱。The searchPattern string "s*" searches for all names in path beginning with the letter "s".

EnumerateFileSystemInfosGetFileSystemInfos 方法的差異如下:The EnumerateFileSystemInfos and GetFileSystemInfos methods differ as follows:

因此,當您使用許多檔案和目錄時,EnumerateFileSystemInfos 可能會更有效率。Therefore, when you are working with many files and directories, EnumerateFileSystemInfos can be more efficient.

這個方法會預先填入下列 FileSystemInfo 屬性的值:This method pre-populates the values of the following FileSystemInfo properties:

傳回的集合不會進行快取;每次呼叫集合上的 GetEnumerator 方法都會啟動新的列舉。The returned collection is not cached; each call to the GetEnumerator method on the collection will start a new enumeration.

適用於