Bewerken

Share via


ResourceReader.GetResourceData(String, String, Byte[]) Method

Definition

Retrieves the type name and data of a named resource from an open resource file or stream.

public:
 void GetResourceData(System::String ^ resourceName, [Runtime::InteropServices::Out] System::String ^ % resourceType, [Runtime::InteropServices::Out] cli::array <System::Byte> ^ % resourceData);
public void GetResourceData (string resourceName, out string resourceType, out byte[] resourceData);
member this.GetResourceData : string * string * Byte[] -> unit
Public Sub GetResourceData (resourceName As String, ByRef resourceType As String, ByRef resourceData As Byte())

Parameters

resourceName
String

The name of a resource.

resourceType
String

When this method returns, contains a string that represents the type name of the retrieved resource. This parameter is passed uninitialized.

resourceData
Byte[]

When this method returns, contains a byte array that is the binary representation of the retrieved type. This parameter is passed uninitialized.

Exceptions

resourceName is null.

resourceName does not exist.

resourceName has an invalid type.

The retrieved resource data is corrupt.

The current ResourceReader object is not initialized, probably because it is closed.

Remarks

The GetResourceData method retrieves the value of a named resource as a byte array. It is typically used when the Value property throws an exception when it tries to retrieve the value of a resource.

resourceType is a string that represents the data type of the resource. It can be any of the following values:

  • The string representation of a ResourceTypeCode enumeration member that indicates the data type of the resource. ResourceTypeCode is a private enumeration that is used by .to indicate that a special binary format is used to store one of 19 common data types. These include the .NET Framework primitive data types (Boolean, Byte, Char, Decimal, Double, Int16, Int32, Int64, Single, SByte, UInt16, UInt32, UInt64), as well as String, DateTime, and TimeSpan, In addition, the ResourceTypeCode enumeration includes the values shown in the following table.

    ResourceTypeCode value Description
    ResourceTypeCode.ByteArray The data is a byte array. This data type commonly results from the call to the ResourceWriter.AddResource(String, Byte[]) method.
    ResourceTypeCode.Null The data is a null reference. This data type commonly results from the call to the ResourceWriter.AddResource(String, Object) method with an object whose value is null.
    ResourceTypeCode.Stream The data is stored in a stream. This data type commonly results from the call to the ResourceWriter.AddResource(String, Stream) or ResourceWriter.AddResource(String, Stream, Boolean) method.

    Assuming that resourceData has not been corrupted, it can usually be converted from a byte array back to its original value by calling a BitConverter or BinaryReader method.

  • A string that contains the fully qualified name of the type whose serialized data is assigned to the resourceData argument (for example, System.String). In addition, for types that are not part of the .NET class library, the string includes the name, version, culture, and public key of the assembly that contains the type. For example, the following string indicates that the serialized data represents an instance of the Person type in the Extensions namespace, which is found in version 1.0 of an assembly named Utility that has no public key and no designated culture.

    Extensions.Person, Utility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

  • The string used to describe the data type in the ResourceWriter.AddResourceData method call.

Applies to

See also