Share via


ResourceWriter Constructores

Definición

Inicializa una nueva instancia de la clase ResourceWriter.

Sobrecargas

ResourceWriter(Stream)

Inicializa una nueva instancia de la clase ResourceWriter que escribe los recursos en la secuencia proporcionada.

ResourceWriter(String)

Inicializa una nueva instancia de la clase ResourceWriter que escribe los recursos en el archivo especificado.

ResourceWriter(Stream)

Source:
ResourceWriter.cs
Source:
ResourceWriter.cs
Source:
ResourceWriter.cs

Inicializa una nueva instancia de la clase ResourceWriter que escribe los recursos en la secuencia proporcionada.

public:
 ResourceWriter(System::IO::Stream ^ stream);
public ResourceWriter (System.IO.Stream stream);
new System.Resources.ResourceWriter : System.IO.Stream -> System.Resources.ResourceWriter
Public Sub New (stream As Stream)

Parámetros

stream
Stream

Secuencia de salida.

Excepciones

El parámetro stream no se puede escribir.

El parámetro stream es null.

Ejemplos

En el ejemplo de código siguiente se define una nueva instancia de la ResourceWriter clase que escribe en una secuencia especificada. El código agrega recursos al escritor y escribe los recursos en la secuencia.

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

Consulte también

Se aplica a

ResourceWriter(String)

Source:
ResourceWriter.cs
Source:
ResourceWriter.cs
Source:
ResourceWriter.cs

Inicializa una nueva instancia de la clase ResourceWriter que escribe los recursos en el archivo especificado.

public:
 ResourceWriter(System::String ^ fileName);
public ResourceWriter (string fileName);
new System.Resources.ResourceWriter : string -> System.Resources.ResourceWriter
Public Sub New (fileName As String)

Parámetros

fileName
String

Nombre del archivo de salida.

Excepciones

El parámetro fileName es null.

Ejemplos

En el ejemplo de código siguiente se define una nueva instancia de la ResourceWriter clase que escribirá en un archivo especificado. El código agrega recursos al escritor y escribe los recursos en el archivo.

using namespace System;
using namespace System::Resources;
int main()
{
   
   // Creates a resource writer.
   IResourceWriter^ writer = gcnew ResourceWriter( "myResources.resources" );
   
   // Adds resources to the resource writer.
   writer->AddResource( "String 1", "First String" );
   writer->AddResource( "String 2", "Second String" );
   writer->AddResource( "String 3", "Third String" );
   
   // Writes the resources to the file or stream, and closes it.
   writer->Close();
}
using System;
using System.Resources;

public class WriteResources {
   public static void Main(string[] args) {

      // Creates a resource writer.
      IResourceWriter writer = new ResourceWriter("myResources.resources");

      // Adds resources to the resource writer.
      writer.AddResource("String 1", "First String");

      writer.AddResource("String 2", "Second String");

      writer.AddResource("String 3", "Third String");

      // Writes the resources to the file or stream, and closes it.
      writer.Close();
   }
}
Imports System.Resources

Public Class WriteResources
    
    Public Shared Sub Main()
        
        ' Creates a resource writer.
        Dim writer As New ResourceWriter("myResources.resources")
        
        ' Adds resources to the resource writer.
        writer.AddResource("String 1", "First String")
        
        writer.AddResource("String 2", "Second String")
        
        writer.AddResource("String 3", "Third String")
        
        ' Writes the resources to the file or stream, and closes it.
        writer.Close()
    End Sub
End Class

Consulte también

Se aplica a