Export (0) Print
Expand All

ResourceReader Constructor (Stream)

Initializes a new instance of the ResourceReader class for the specified stream.

Namespace: System.Resources
Assembly: mscorlib (in mscorlib.dll)

public ResourceReader (
	Stream stream
)
public ResourceReader (
	Stream stream
)
public function ResourceReader (
	stream : Stream
)

Parameters

stream

The input stream for reading resources.

Exception typeCondition

ArgumentException

The stream is not readable.

ArgumentNullException

The stream parameter is a null reference (Nothing in Visual Basic).

IOException

An I/O error has occured while accessing stream.

using System;
using System.Resources;
using System.Collections;
using System.IO;
 
public class ReadResources 
{
    public static void Main(string[] args) 
    {
        // Create a file stream to encapsulate items.resources.
        FileStream fs = new FileStream("items.resources", FileMode.Open);

        // Open a resource reader to read from the stream. 
        IResourceReader reader = new ResourceReader(fs);
		
        // Get an enumerator for the reader.
        IDictionaryEnumerator en = reader.GetEnumerator();
      
        // Enumerate through the file, printing out the key/value pairs.
        while (en.MoveNext()) 
        {
            Console.WriteLine();
            Console.WriteLine("Name: {0}", en.Key);
            Console.WriteLine("Value: {0}", en.Value);
        }
        fs.Close();		
        reader.Close();
    }
}

import System.*;
import System.Resources.*;
import System.Collections.*;
import System.IO.*;

public class ReadResources
{

    public static void main(String[] args)
    {
        // Create a file stream to encapsulate items.resources.
        FileStream fs = new FileStream("items.resources", FileMode.Open);

        // Open a resource reader to read from the stream. 
        IResourceReader reader = new ResourceReader(fs);

        // Get an enumerator for the reader.
        IDictionaryEnumerator en = reader.GetEnumerator();

        // Enumerate through the file, printing out the key/value pairs.
        while (en.MoveNext()) {
            Console.WriteLine();
            Console.WriteLine("Name: {0}", en.get_Key());
            Console.WriteLine("Value: {0}", en.get_Value());
        }
        fs.Close();
        reader.Close();
    } //main
} //ReadResources

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft