ResourceReader::GetResourceData Method (String^, String^%, array<Byte>^%)
Retrieves the type name and data of a named resource from an open resource file or stream.
Assembly: mscorlib (in mscorlib.dll)
public: void GetResourceData( String^ resourceName, [OutAttribute] String^% resourceType, [OutAttribute] array<unsigned char>^% resourceData )
Parameters
- resourceName
-
Type:
System::String^
The name of a resource.
- resourceType
-
Type:
System::String^%
When this method returns, contains a string that represents the type name of the retrieved resource (see the Remarks section for details). This parameter is passed uninitialized.
- resourceData
-
Type:
array<System::Byte>^%
When this method returns, contains a byte array that is the binary representation of the retrieved type. This parameter is passed uninitialized.
| Exception | Condition |
|---|---|
| ArgumentNullException | resourceName is null. |
| ArgumentException | resourceName does not exist. |
| BadImageFormatException | resourceName has an invalid type. |
| FormatException | The retrieved resource data is corrupt. |
| InvalidOperationException | The current ResourceReader object is not initialized, probably because it is closed. |
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^, array<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 Framework 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
Assuming that resourceData has not been corrupted and that the source type is available, resourceData can be converted from a byte array back to its original value by converting the byte array to a Stream object and passing the stream to the BinaryFormatter::Deserialize method.
The string used to describe the data type in the ResourceWriter::AddResourceData method call.
Available since 2.0