IsolatedStorageFileStream.Close メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
IsolatedStorageFileStream オブジェクトに関連付けられたリソースを解放します。
public:
override void Close();
public override void Close ();
override this.Close : unit -> unit
Public Overrides Sub Close ()
例
次のコード例は、Close メソッドを示しています。
IsolatedStorageFileStream source =
new IsolatedStorageFileStream(this.userName,FileMode.Open,isoFile);
// This stream is the one that data will be read from
Console.WriteLine("Source can be read?" + (source.CanRead?"true":"false"));
IsolatedStorageFileStream target =
new IsolatedStorageFileStream("Archive\\ " + this.userName,FileMode.OpenOrCreate,isoFile);
// This stream is the one that data will be written to
Console.WriteLine("Target is writable?" + (target.CanWrite?"true":"false"));
// Do work...
// After you have read and written to the streams, close them
source.Close();
target.Close();
Dim source As New IsolatedStorageFileStream(UserName,FileMode.Open,isoFile)
' This stream is the one that data will be read from
If source.CanRead Then
Console.WriteLine("Source can read ? true")
Else
Console.WriteLine("Source can read ? false")
End If
Dim target As New IsolatedStorageFileStream("Archive\\ " & UserName, _
FileMode.OpenOrCreate, _
isoFile)
' This stream is the one that data will be written to
If target.CanWrite Then
Console.WriteLine("Target is writable? true")
Else
Console.WriteLine("Target is writable? false")
End If
' After you have read and written to the streams, close them
source.Close()
target.Close()
注釈
バッファーに以前に書き込まれたデータは、ファイル ストリームが閉じられる前にファイルにコピーされるため、Close を呼び出す前に を呼び出 Flush す必要はありません。
Close の呼び出しの後、ファイル ストリームに対するすべての操作で例外が発生する可能性があります。 が 1 回呼び出された後 Close
、再度呼び出された場合は何も行いません。 メソッドは Finalize() Close を呼び出して、ガベージ コレクターがオブジェクトを終了する前にファイル ストリームを閉じます。
IsolatedStorageFileStream オブジェクトには、 IsolatedStorageFile アクセスされるファイルのストレージ コンテキストを決定する オブジェクトが必要です。 オブジェクトを IsolatedStorageFile 渡さずに開かれたストリームの場合、実行中のアセンブリに対して既定 IsolatedStorageFile のオブジェクトが作成され、Close の呼び出し中に閉じられます。
注意
メソッドは Close
、disposing を true に設定して を呼び出 Dispose してリソースを解放し、 を呼び出 SuppressFinalize してガベージ コレクターによるこのオブジェクトの最終処理を抑制します。
適用対象
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示