Export (0) Print
Expand All

ResourceReader Constructor (String)

Initializes a new instance of the ResourceReader class for the specified resource file.

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

public ResourceReader (
	string fileName
)
public ResourceReader (
	String fileName
)
public function ResourceReader (
	fileName : String
)

Parameters

fileName

The path of the resource file to be read.

Exception typeCondition

ArgumentNullException

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

FileNotFoundException

The file cannot be found.

IOException

An I/O error has occured.

using System;
using System.Resources;
using System.Collections;
 
public class ReadResources {

   public static void Main(string[] args) {

      // Opens a resource reader and gets an enumerator from it.
      IResourceReader reader = new ResourceReader("myResources.resources");
      IDictionaryEnumerator en = reader.GetEnumerator();
      
      // Goes through the enumerator, printing out the key and value pairs.
      while (en.MoveNext()) {
         Console.WriteLine();
         Console.WriteLine("Name: {0}", en.Key);
         Console.WriteLine("Value: {0}", en.Value);
      }
      reader.Close();
   }
}

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

public class ReadResources
{
    public static void main(String[] args)
    {
        // Opens a resource reader and gets an enumerator from it.
        IResourceReader reader = new ResourceReader("myResources.resources");
        IDictionaryEnumerator en = reader.GetEnumerator();

        // Goes through the enumerator, printing out the key and value pairs.
        while(en.MoveNext()) {
            Console.WriteLine();
            Console.WriteLine("Name: {0}", en.get_Key());
            Console.WriteLine("Value: {0}", en.get_Value());
        }
        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