DirectoryInfo.EnumerateFileSystemInfos 方法

定義

傳回目前目錄中檔案系統資訊的可列舉集合。

多載

EnumerateFileSystemInfos(String, SearchOption)

傳回符合指定之搜尋模式和搜尋子目錄選項的檔案系統資訊的可列舉集合。

EnumerateFileSystemInfos()

傳回目前目錄中檔案系統資訊的可列舉集合。

EnumerateFileSystemInfos(String)

傳回符合指定之搜尋模式的檔案系統資訊的可列舉集合。

EnumerateFileSystemInfos(String, EnumerationOptions)

傳回符合所指定搜尋模式和列舉選項之檔案系統資訊的可列舉集合。

EnumerateFileSystemInfos(String, SearchOption)

來源:
DirectoryInfo.cs
來源:
DirectoryInfo.cs
來源:
DirectoryInfo.cs

傳回符合指定之搜尋模式和搜尋子目錄選項的檔案系統資訊的可列舉集合。

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

傳回

符合 searchPatternsearchOption 的檔案系統資訊的可列舉集合。

例外狀況

searchPatternnull

searchOption 不是有效的 SearchOption 值。

DirectoryInfo 物件中封裝的路徑無效 (例如它位於未對應的磁碟機上)。

呼叫端沒有必要的權限。

備註

searchPattern 可以是常值和通配符的組合,但不支援正則表達式。 在中 searchPattern允許下列通配符規範。

通配符規範 相符項
* (星號) 該位置中的零或多個字元。
? (問號) 該位置中的零或一個字元。

通配符以外的字元是常值字元。 例如,字串 「*t」 會搜尋以字母 「t」 結尾的所有名稱。 ". 字串 “s*” 會 searchPattern 以字母 “s” 開頭搜尋所有名稱 path

EnumerateFileSystemInfosGetFileSystemInfos 方法會如下所示:

因此,當您使用許多檔案和目錄時, EnumerateFileSystemInfos 可能會更有效率。

這個方法會預先填入下列 FileSystemInfo 屬性的值:

未快取傳回的集合;集合上對方法的每個呼叫 GetEnumerator 都會啟動新的列舉。

另請參閱

適用於

EnumerateFileSystemInfos()

來源:
DirectoryInfo.cs
來源:
DirectoryInfo.cs
來源:
DirectoryInfo.cs

傳回目前目錄中檔案系統資訊的可列舉集合。

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

呼叫端沒有必要的權限。

備註

EnumerateFileSystemInfosGetFileSystemInfos 方法會如下所示:

因此,當您使用許多檔案和目錄時, EnumerateFileSystemInfos 可能會更有效率。

這個方法會預先填入下列 FileSystemInfo 屬性的值:

未快取傳回的集合;集合上對方法的每個呼叫 GetEnumerator 都會啟動新的列舉。

另請參閱

適用於

EnumerateFileSystemInfos(String)

來源:
DirectoryInfo.cs
來源:
DirectoryInfo.cs
來源:
DirectoryInfo.cs

傳回符合指定之搜尋模式的檔案系統資訊的可列舉集合。

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 的檔案系統資訊的可列舉集合。

例外狀況

searchPatternnull

DirectoryInfo 物件中封裝的路徑無效 (例如它位於未對應的磁碟機上)。

呼叫端沒有必要的權限。

備註

searchPattern 可以是常值和通配符的組合,但不支援正則表達式。 在中 searchPattern允許下列通配符規範。

通配符規範 相符項
* (星號) 該位置中的零或多個字元。
? (問號) 該位置中的零或一個字元。

通配符以外的字元是常值字元。 例如,字串 「*t」 會搜尋以字母 「t」 結尾的所有名稱。 ". 字串 “s*” 會 searchPattern 以字母 “s” 開頭搜尋所有名稱 path

EnumerateFileSystemInfosGetFileSystemInfos 方法會如下所示:

因此,當您使用許多檔案和目錄時, EnumerateFileSystemInfos 可能會更有效率。

這個方法會預先填入下列 FileSystemInfo 屬性的值:

未快取傳回的集合;集合上對方法的每個呼叫 GetEnumerator 都會啟動新的列舉。

另請參閱

適用於

EnumerateFileSystemInfos(String, EnumerationOptions)

來源:
DirectoryInfo.cs
來源:
DirectoryInfo.cs
來源:
DirectoryInfo.cs

傳回符合所指定搜尋模式和列舉選項之檔案系統資訊的可列舉集合。

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

物件,描述要使用的搜尋和列舉組態。

傳回

符合 searchPatternenumerationOptions 的檔案系統資訊的可列舉集合。

例外狀況

searchPatternnull

DirectoryInfo 物件中封裝的路徑無效 (例如它位於未對應的磁碟機上)。

呼叫端沒有必要的權限。

備註

searchPattern 可以是常值和通配符的組合,但不支援正則表達式。 在中 searchPattern允許下列通配符規範。

通配符規範 相符項
* (星號) 該位置中的零或多個字元。
? (問號) 該位置中的零或一個字元。

通配符以外的字元是常值字元。 例如,字串 「*t」 會搜尋以字母 「t」 結尾的所有名稱。 ". 字串 “s*” 會 searchPattern 以字母 “s” 開頭搜尋所有名稱 path

EnumerateFileSystemInfosGetFileSystemInfos 方法會如下所示:

因此,當您使用許多檔案和目錄時, EnumerateFileSystemInfos 可能會更有效率。

這個方法會預先填入下列 FileSystemInfo 屬性的值:

未快取傳回的集合;集合上對方法的每個呼叫 GetEnumerator 都會啟動新的列舉。

適用於