ResourceWriter.Dispose-Methode
Ermöglicht Benutzern das Schließen der Ressourcendatei oder des Streams, um Ressourcen explizit freizugegeben.
Namespace: System.Resources
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Sub Dispose
'Usage
Dim instance As ResourceWriter
instance.Dispose
public void Dispose ()
public:
virtual void Dispose () sealed
public final void Dispose ()
public final function Dispose ()
Ausnahmen
Ausnahmetyp | Bedingung |
---|---|
Ein E/A-Fehler ist aufgetreten. |
|
Während der Serialisierung des Objekts ist ein Fehler aufgetreten. |
Hinweise
Die Implementierung dieser Methode entspricht Close.
Beispiel
Imports System
Imports System.Resources
Imports System.IO
Public Class WriteResources
Public Shared Sub Main(ByVal 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 clean up all resources associated with the writer.
' Calling Dispose is equivalent to calling Close.
writer.Dispose()
End Sub
End Class
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 clean up all resources associated with the writer.
// Calling Dispose is equivalent to calling Close.
writer.Dispose();
}
}
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 clean up all resources associated with the writer.
// Calling Dispose is equivalent to calling Close.
writer->~IResourceWriter();
}
import System.*;
import System.Resources.*;
import 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 clean up all resources associated with the writer.
// Calling Dispose is equivalent to calling Close.
writer.Dispose();
} //main
} //WriteResources
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
ResourceWriter-Klasse
ResourceWriter-Member
System.Resources-Namespace
IDisposable