ResourceWriterとは? わかりやすく解説

ResourceWriter クラス

システムの既定の形式で、リソースを出力ファイルまたは出力ストリームに書き込みます。このクラスは継承できません。

名前空間: System.Resources
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ComVisibleAttribute(True)> _
Public NotInheritable Class
 ResourceWriter
    Implements IResourceWriter, IDisposable
Dim instance As ResourceWriter
[ComVisibleAttribute(true)] 
public sealed class ResourceWriter : IResourceWriter,
 IDisposable
[ComVisibleAttribute(true)] 
public ref class ResourceWriter sealed : IResourceWriter,
 IDisposable
/** @attribute ComVisibleAttribute(true) */ 
public final class ResourceWriter implements
 IResourceWriter, IDisposable
ComVisibleAttribute(true) 
public final class ResourceWriter implements
 IResourceWriter, IDisposable
解説解説
使用例使用例

myResources.resources ファイルにいくつかの文字列を書き込む例を次に示します。

Imports System
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
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();
   }
}
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();
}

import System.*;
import 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();
    } //main
} //WriteResources
継承階層継承階層
System.Object
  System.Resources.ResourceWriter
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ResourceWriter コンストラクタ (Stream)

指定したストリームにリソースを書き込む ResourceWriter クラスの新しいインスタンスを初期化します。

名前空間: System.Resources
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

例外例外
例外の種類条件

ArgumentException

stream パラメータが書き込み可能ではありません。

ArgumentNullException

stream パラメータが null 参照 (Visual Basic では Nothing) です。

使用例使用例
Imports System
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
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();
    }
}
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();
}

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 close it.
        writer.Close();
    } //main
} //WriteResources
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ResourceWriter コンストラクタ (String)

指定したファイルにリソースを書き込む ResourceWriter クラスの新しいインスタンスを初期化します。

名前空間: System.Resources
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

例外例外
例外の種類条件

ArgumentNullException

fileName パラメータが null 参照 (Visual Basic では Nothing) です。

使用例使用例
Imports System
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
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();
   }
}
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();
}

import System.*;
import 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();
    } //main
} //WriteResources
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ResourceWriter コンストラクタ


ResourceWriter メソッド


パブリック メソッドパブリック メソッド

参照参照

ResourceWriter メンバ

システムの既定の形式で、リソースを出力ファイルまたは出力ストリームに書き込みます。このクラスは継承できません。

ResourceWriter データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
パブリック メソッドパブリック メソッド
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「ResourceWriter」の関連用語

ResourceWriterのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ResourceWriterのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS