共用方式為


ResourceWriter 建構函式

定義

初始化 ResourceWriter 類別的新執行個體。

多載

ResourceWriter(Stream)

初始化 ResourceWriter 類別的新執行個體,這個執行個體可將資源寫入提供的資料流。

ResourceWriter(String)

初始化 ResourceWriter 類別的新執行個體,這個執行個體會將資源寫入指定的檔案。

ResourceWriter(Stream)

來源:
ResourceWriter.cs
來源:
ResourceWriter.cs
來源:
ResourceWriter.cs

初始化 ResourceWriter 類別的新執行個體,這個執行個體可將資源寫入提供的資料流。

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)

參數

stream
Stream

輸出資料流。

例外狀況

stream 參數是不可寫入的。

stream 參數為 null

範例

下列程式代碼範例會定義 類別的新實例,該實例 ResourceWriter 會寫入指定的數據流。 程式代碼會將資源新增至寫入器,並將資源寫入數據流。

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

另請參閱

適用於

ResourceWriter(String)

來源:
ResourceWriter.cs
來源:
ResourceWriter.cs
來源:
ResourceWriter.cs

初始化 ResourceWriter 類別的新執行個體,這個執行個體會將資源寫入指定的檔案。

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

參數

fileName
String

輸出檔案名稱。

例外狀況

fileName 參數為 null

範例

下列程式代碼範例會定義 類別的新實例 ResourceWriter ,以寫入指定的檔案。 程式代碼會將資源新增至寫入器,並將資源寫入檔案。

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

另請參閱

適用於