Assembly.GetFile(String) 方法

定義

取得指定之檔案的 FileStream,這個指定之檔案位於這個組件的資訊清單檔案表中。

C#
public virtual System.IO.FileStream? GetFile(string name);
C#
public virtual System.IO.FileStream GetFile(string name);

參數

name
String

指定檔案的名稱。 切勿包括該檔案的路徑。

傳回

包含指定之檔案的資料流,如果找不到檔案則為 null

實作

例外狀況

無法載入找到的檔案。

name 參數為 null

name 參數是空字串 ("")。

找不到 name

name 不是有效的組件。

備註

這個方法適用於公用和私人資源檔。

name 變數不應該包含檔案的路徑。

在 .NET 5 和更新版本中,針對配套的元件,此方法會擲回例外狀況。

適用於

產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1