ResourceWriter.Dispose メソッド
リソース ファイルまたはストリームを閉じ、明示的にリソースを解放できます。
Public Overridable Sub Dispose() Implements IDisposable.Dispose
[C#]
public virtual void Dispose();
[C++]
public: virtual void Dispose();
[JScript]
public function Dispose();
実装
例外
例外の種類 | 条件 |
---|---|
IOException | I/O エラーが発生しました。 |
SerializationException | オブジェクトのシリアル化でエラーが発生しました。 |
解説
メソッドの実装は Close と同じです。
使用例
Imports System
Imports System.Resources
Imports System.IO
Public Class WriteResources
Public Shared Sub Main(ByVal 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 clean up all resources associated with the writer.
' Calling Dispose is equivalent to calling Close.
writer.Dispose()
End Sub
End Class
[C#]
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 clean up all resources associated with the writer.
// Calling Dispose is equivalent to calling Close.
writer.Dispose();
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
using namespace System::Resources;
using namespace System::IO;
int main() {
// Create a file stream to encapsulate items.resources.
FileStream* fs = new FileStream(S"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(S"String 1", S"First String");
writer->AddResource(S"String 2", S"Second String");
writer->AddResource(S"String 3", S"Third String");
// Write the resources to the stream,
// and clean up all resources associated with the writer.
// Calling Dispose is equivalent to calling Close.
writer->Dispose();
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
ResourceWriter クラス | ResourceWriter メンバ | System.Resources 名前空間 | IDisposable