ResourceWriter::Close Method ()

 

Saves the resources to the output stream and then closes it.

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

public:
virtual void Close() sealed

Exception Condition
IOException

An I/O error has occurred.

SerializationException

An error has occurred during serialization of the object.

Generate is called implicitly by Close, if required.

The following example uses the Close method to write all resource objects in a ResourceWriter class to the output stream. The code then shuts down the writer.

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: