ResourceWriter 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 ResourceWriter 类的新实例。
重载
ResourceWriter(Stream) |
初始化 ResourceWriter 类的新实例,它将资源写入到提供的流中。 |
ResourceWriter(String) |
初始化 ResourceWriter 类的新实例,它将资源写入到指定文件中。 |
ResourceWriter(Stream)
- Source:
- ResourceWriter.cs
- Source:
- ResourceWriter.cs
- Source:
- 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)
- Source:
- ResourceWriter.cs
- Source:
- ResourceWriter.cs
- Source:
- 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