IsolatedStorageFileStream.Close 메서드

정의

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()

설명

이전에 버퍼에 기록된 모든 데이터는 파일 스트림이 닫히기 전에 파일에 복사되므로 닫기를 호출하기 전에 호출 Flush 할 필요가 없습니다.

Close를 호출한 후 파일 스트림에 대한 모든 작업에서 예외가 발생할 수 있습니다. 한 번 호출된 후에 Close 는 다시 호출하면 아무 것도 수행하지 않습니다. 메서드는 Finalize() 가비지 수집기가 개체를 완료하기 전에 파일 스트림이 닫히도록 Close를 호출합니다.

IsolatedStorageFileStream 개체에는 액세스된 파일의 스토리지 컨텍스트를 결정하는 IsolatedStorageFile 개체가 필요합니다. 개체를 전달 IsolatedStorageFile 하지 않고 열린 스트림의 경우 실행 중인 어셈블리에 대한 기본 IsolatedStorageFile 개체가 만들어진 다음 Close 호출 중에 닫힙니다.

참고

이 메서드 DisposeClose 삭제 집합을 true로 설정하여 리소스를 해제한 다음 가비지 수집기에서 이 개체의 종료를 표시하지 않는 호출을 호출 SuppressFinalize 합니다.

적용 대상