Assembly.GetManifestResourceStream 方法

定義

載入來自這個組件的指定資訊清單資源。

多載

GetManifestResourceStream(Type, String)

從這個組件載入指定資訊清單資源,由指定類型的命名空間限定範圍。

GetManifestResourceStream(String)

載入來自這個組件的指定資訊清單資源。

GetManifestResourceStream(Type, String)

來源:
Assembly.cs
來源:
Assembly.cs
來源:
Assembly.cs

從這個組件載入指定資訊清單資源,由指定類型的命名空間限定範圍。

public:
 virtual System::IO::Stream ^ GetManifestResourceStream(Type ^ type, System::String ^ name);
public virtual System.IO.Stream? GetManifestResourceStream (Type type, string name);
public virtual System.IO.Stream GetManifestResourceStream (Type type, string name);
abstract member GetManifestResourceStream : Type * string -> System.IO.Stream
override this.GetManifestResourceStream : Type * string -> System.IO.Stream
Public Overridable Function GetManifestResourceStream (type As Type, name As String) As Stream

參數

type
Type

類型,其命名空間是用來限定資訊清單資源名稱的範圍。

name
String

所要求的資訊清單資源的區分大小寫名稱。

傳回

資訊清單資源,而如果編譯期間未指定資源或是呼叫者看不到該資源,則為 null

實作

例外狀況

name 參數為 null

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

無法載入找到的檔案。

找不到 name

name 不是有效的組件。

資源長度大於 Int64.MaxValue

備註

例如,如果指定 type 的完整名稱是 「MyNameSpace.MyClasses」,且 name 為 「Net」,這個方法多載會搜尋名為 「MyNameSpace.Net」 的資源。

資訊清單資源是資源 (,例如在編譯時期內嵌在元件中的影像檔) 。 如需資訊清單資源的詳細資訊,請參閱Microsoft .NET Framework資源基本概念

只有在呼叫端看得見資源,或呼叫端具有 ReflectionPermission 時,才會傳回資源資訊。

注意

如果存取另一個元件中的私人資源,而且呼叫端沒有 ReflectionPermissionReflectionPermissionFlag.MemberAccess 標,這個方法會傳回 null

如果元件資訊清單列出資源檔,則會傳回 Stream 物件, GetManifestResourceStream 即使當時在磁片上找不到資源檔也一樣。 如果找不到資源檔,將產生的 Stream 物件傳遞至 ResourceReader 建構函式會導致 ArgumentException

另請參閱

適用於

GetManifestResourceStream(String)

來源:
Assembly.cs
來源:
Assembly.cs
來源:
Assembly.cs

載入來自這個組件的指定資訊清單資源。

public:
 virtual System::IO::Stream ^ GetManifestResourceStream(System::String ^ name);
public virtual System.IO.Stream GetManifestResourceStream (string name);
public virtual System.IO.Stream? GetManifestResourceStream (string name);
abstract member GetManifestResourceStream : string -> System.IO.Stream
override this.GetManifestResourceStream : string -> System.IO.Stream
Public Overridable Function GetManifestResourceStream (name As String) As Stream

參數

name
String

所要求的資訊清單資源的區分大小寫名稱。

傳回

資訊清單資源,而如果編譯期間未指定資源或是呼叫者看不到該資源,則為 null

實作

例外狀況

name 參數為 null

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

無法載入找到的檔案。

注意:在 適用于 Windows 市集應用程式的 .NET可攜式類別庫中,改為攔截基類例外狀況 IOException

找不到 name

name 不是有效的組件。

資源長度大於 Int64.MaxValue

備註

資訊清單資源是資源 (,例如在編譯時期內嵌在元件中的影像檔) 。 如需資訊清單資源的詳細資訊,請參閱Microsoft .NET Framework資源基本概念

只有在呼叫端看得見資源,或呼叫端具有 ReflectionPermission 時,才會傳回資源資訊。

注意

如果存取另一個元件中的私人資源,而且呼叫端沒有 ReflectionPermissionReflectionPermissionFlag.MemberAccess 標,這個方法會傳回 null

如果元件資訊清單列出資源檔,則會傳回 Stream 物件, GetManifestResourceStream 即使當時在磁片上找不到資源檔也一樣。 如果找不到資源檔,將產生的 Stream 物件傳遞至 ResourceReader 建構函式會導致 ArgumentException

另請參閱

適用於