ResourceWriter.Dispose Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Kullanıcıların kaynakları açıkça serbest bırakarak kaynak dosyasını veya akışı kapatmasına izin verir.
public:
virtual void Dispose();
public void Dispose();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Sub Dispose ()
Uygulamalar
Özel durumlar
G/Ç hatası oluştu.
Nesne seri hale getirilirken bir hata oluştu.
Örnekler
Aşağıdaki kod örneği, bir Dispose sınıftaki ResourceWriter tüm kaynak nesnelerini çıkış akışına yazmak için yöntemini kullanır. Kod daha sonra yazıcıyı kapatır ve yazarın kaynaklarını diğer işlemler için kullanılabilir hale getirir.
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();
}
}
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
Açıklamalar
Bu yöntemin uygulanması ile aynıdır Close.