ResourceReader Constructor (Stream^)
Initializes a new instance of the ResourceReader class for the specified stream.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- stream
-
Type:
System.IO::Stream^
The input stream for reading resources.
| Exception | Condition |
|---|---|
| ArgumentException | The stream parameter is not readable. |
| ArgumentNullException | The stream parameter is null. |
| IOException | An I/O error has occurred while accessing stream. |
The ResourceReader(Stream^) constructor instantiates a ResourceReader object that retrieves resources either from a standalone .resources file or from a .resources file that is embedded in an assembly. To read from a standalone .resources file, instantiate a Stream object and pass it to the ResourceReader(Stream^) constructor. To read from an embedded .resources file, call the Assembly::GetManifestResourceStream method with the case-sensitive name of the .resources file, and pass the returned Stream object to the ResourceReader(Stream^) constructor.
Security Note
|
|---|
Using an instance of this object with untrusted data is a security risk. Use this object only with trusted data. For more information, see Untrusted Data Security Risks. |
The example in this section uses the following .txt file named PatientForm.txt to define the resources used by an application.
Title="Top Pet Animal Clinic" Label1="Patient Number:" Label2="Pet Name:" Label3="Species:" Label4="Breed:" Label5="Date of Birth:" Label6="Age:" Label7="Owner:" Label8="Address:" Label9="Home Phone:" Label10="Work Phone:" Label11="Mobile Phone:"
You can compile the .txt file into a .resources file by issuing the following command:
resgen PatientForm.txt
The following example assumes that the resource file is embedded in the assembly that contains the application's executable code. It retrieves a resource file named PatientForm.resources from the currently executing assemblies and displays the name and value of each of its resources.
If the C# example is named Example.cs, you can compile it by using the following command:
csc Example.cs /res:PatientForm.resources
If the Visual Basic example is named Example.vb, you can compile it by using the following command:
vbc Example.vb /res:PatientForm.resources
for providing serialization services. Security action: LinkDemand. Associated enumeration: SerializationFormatter
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Available since 1.1
