ResourceWriter.Close Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Salva le risorse nel flusso di output e lo chiude.
public:
virtual void Close();
public void Close ();
abstract member Close : unit -> unit
override this.Close : unit -> unit
Public Sub Close ()
Implementazioni
Eccezioni
Si è verificato un errore di I/O.
Si è verificato un errore durante la serializzazione dell'oggetto.
Esempio
Nell'esempio seguente viene usato il Close metodo per scrivere tutti gli oggetti risorsa in una ResourceWriter classe nel flusso di output. Il codice arresta quindi il 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();
}
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();
}
}
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
Commenti
Generate viene chiamato in modo implicito da Close, se necessario.