ResourceWriter.Close Method
.NET Framework 1.1
Saves the resources to the output stream and then closes it.
[Visual Basic] Public Overridable Sub Close() Implements IResourceWriter.Close [C#] public virtual void Close(); [C++] public: virtual void Close(); [JScript] public function Close();
Implements
Exceptions
| Exception Type | Condition |
|---|---|
| IOException | An I/O error has occurred. |
| SerializationException | An error has occurred during serialization of the object. |
Remarks
Generate is called implicitly by Close, if required.
Example
[Visual Basic] Imports System Imports System.Resources Imports System.IO Public Class WriteResources Public Shared Sub Main(args() As String) ' Create a file stream to encapsulate items.resources. Dim fs As New FileStream("items.resources", _ FileMode.OpenOrCreate, FileAccess.Write) ' Open a resource writer to write from the stream. Dim writer = New 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() End Sub End Class [C#] using System; using System.Resources; using System.IO; public class WriteResources { public static void Main(string[] args) { // Create a file stream to encapsulate items.resources. FileStream fs = new FileStream("items.resources", FileMode.OpenOrCreate,FileAccess.Write); // Open a resource writer to write from the stream. IResourceWriter writer = new 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(); } } [C++] #using <mscorlib.dll> using namespace System; using namespace System::Resources; using namespace System::IO; int main() { // Create a file stream to encapsulate items.resources. FileStream* fs = new FileStream(S"items.resources", FileMode::OpenOrCreate, FileAccess::Write); // Open a resource writer to write from the stream. IResourceWriter* writer = new ResourceWriter(fs); // Add resources to the resource writer. writer->AddResource(S"String 1", S"First String"); writer->AddResource(S"String 2", S"Second String"); writer->AddResource(S"String 3", S"Third String"); // Write the resources to the stream, and close it. writer->Close(); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
ResourceWriter Class | ResourceWriter Members | System.Resources Namespace