ResourceWriter Constructor (Stream^)

 

Initializes a new instance of the ResourceWriter class that writes the resources to the provided stream.

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

public:
ResourceWriter(
	Stream^ stream
)

Parameters

stream
Type: System.IO::Stream^

The output stream.

Exception Condition
ArgumentException

The stream parameter is not writable.

ArgumentNullException

The stream parameter is null.

The following code example defines a new instance of the ResourceWriter class that writes to a specified stream. The code adds resources to the writer and writes the resources to the stream.

using namespace System;
using namespace System::Resources;
using namespace System::IO;
int main()
{

   // Create a file stream to encapsulate items.resources.
   FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write );

   // Open a resource writer to write from the stream.
   IResourceWriter^ writer = gcnew ResourceWriter( fs );

   // Add resources to the resource writer.
   writer->AddResource( "String 1", "First String" );
   writer->AddResource( "String 2", "Second String" );
   writer->AddResource( "String 3", "Third String" );

   // Write the resources to the stream, and close it.
   writer->Close();
}

.NET Framework
Available since 1.1
Return to top
Show: