EndOfStreamException EndOfStreamException EndOfStreamException EndOfStreamException Class

정의

읽을 때 throw되는 예외가 스트림의 끝을 지나 시도됩니다.The exception that is thrown when reading is attempted past the end of a stream.

public ref class EndOfStreamException : System::IO::IOException
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class EndOfStreamException : System.IO.IOException
type EndOfStreamException = class
    inherit IOException
Public Class EndOfStreamException
Inherits IOException
상속
특성

예제

다음 코드 예제에는 읽기 및 쓰기는 방법을 보여 줍니다 Double 를 사용 하 여 메모리 데이터를 BinaryReaderBinaryWriter 의 맨 위에 있는 클래스는 MemoryStream 클래스.The following code example shows how to read and write Double data to memory by using the BinaryReader and BinaryWriter classes on top of the MemoryStream class.

using namespace System;
using namespace System::IO;
int main()
{
   int i;
   const int arrayLength = 1000;
   
   // Create random data to write to the stream.
   array<double>^dataArray = gcnew array<double>(arrayLength);
   Random^ randomGenerator = gcnew Random;
   for ( i = 0; i < arrayLength; i++ )
   {
      dataArray[ i ] = 100.1 * randomGenerator->NextDouble();

   }
   BinaryWriter^ binWriter = gcnew BinaryWriter( gcnew MemoryStream );
   try
   {
      
      // Write data to the stream.
      Console::WriteLine( "Writing data to the stream." );
      i = 0;
      for ( i = 0; i < arrayLength; i++ )
      {
         binWriter->Write( dataArray[ i ] );

      }
      
      // Create a reader using the stream from the writer.
      BinaryReader^ binReader = gcnew BinaryReader( binWriter->BaseStream );
      
      // Return to the beginning of the stream.
      binReader->BaseStream->Position = 0;
      try
      {
         
         // Read and verify the data.
         i = 0;
         Console::WriteLine( "Verifying the written data." );
         for ( i = 0; i < arrayLength; i++ )
         {
            if ( binReader->ReadDouble() != dataArray[ i ] )
            {
               Console::WriteLine( "Error writing data." );
               break;
            }

         }
         Console::WriteLine( "The data was written and verified." );
      }
      catch ( EndOfStreamException^ e ) 
      {
         Console::WriteLine( "Error writing data: {0}.", e->GetType()->Name );
      }

   }
   finally
   {
      binWriter->Close();
   }

}

using System;
using System.IO;

class BinaryRW
{
    static void Main()
    {
        int i;
        const int arrayLength = 1000;

        // Create random data to write to the stream.
        Random randomGenerator = new Random();
        double[] dataArray = new double[arrayLength];
        for(i = 0; i < arrayLength; i++)
        {
            dataArray[i] = 100.1 * randomGenerator.NextDouble();
        }

        using(BinaryWriter binWriter = 
            new BinaryWriter(new MemoryStream()))
        {
            // Write the data to the stream.
            Console.WriteLine("Writing data to the stream.");
            for(i = 0; i < arrayLength; i++)
            {
                binWriter.Write(dataArray[i]);
            }

            // Create a reader using the stream from the writer.
            using(BinaryReader binReader = 
                new BinaryReader(binWriter.BaseStream))
            {
                try
                {
                    // Return to the beginning of the stream.
                    binReader.BaseStream.Position = 0;

                    // Read and verify the data.
                    Console.WriteLine("Verifying the written data.");
                    for(i = 0; i < arrayLength; i++)
                    {
                        if(binReader.ReadDouble() != dataArray[i])
                        {
                            Console.WriteLine("Error writing data.");
                            break;
                        }
                    }
                    Console.WriteLine("The data was written " +
                        "and verified.");
                }
                catch(EndOfStreamException e)
                {
                    Console.WriteLine("Error writing data: {0}.",
                        e.GetType().Name);
                }
            }
        }
    }
}
Imports System.IO

Public Class BinaryRW

    Shared Sub Main()
    
        Dim i As Integer
        Const upperBound As Integer = 1000

        ' Create random data to write to the stream.
        Dim dataArray(upperBound) As Double
        Dim randomGenerator As New Random()
        For i = 0 To upperBound
            dataArray(i) = 100.1 * randomGenerator.NextDouble()
        Next i

        Dim binWriter As New BinaryWriter(New MemoryStream())
        Try

            ' Write data to the stream.
            Console.WriteLine("Writing data to the stream.")
            
            For i = 0 To upperBound
                binWriter.Write(dataArray(i))
            Next i

            ' Create a reader using the stream from the writer.
            Dim binReader As New BinaryReader(binWriter.BaseStream)

            ' Return to the beginning of the stream.
            binReader.BaseStream.Position = 0

            ' Read and verify the data.
            Try
                Console.WriteLine("Verifying the written data.")
                For i = 0 To upperBound
                    If binReader.ReadDouble() <> dataArray(i) Then
                        Console.WriteLine("Error writing data.")
                        Exit For
                    End If
                Next i
                Console.WriteLine("The data was written and verified.")
            Catch ex As EndOfStreamException
                Console.WriteLine("Error writing data: {0}.", _
                    ex.GetType().Name)
            End Try
        Finally
            binWriter.Close()
        End Try

    End Sub
End Class

설명

EndOfStreamException 값 0x80070026 HRESULT COR_E_ENDOFSTREAM를 사용 합니다.EndOfStreamException uses the HRESULT COR_E_ENDOFSTREAM which has the value 0x80070026.

생성자

EndOfStreamException() EndOfStreamException() EndOfStreamException() EndOfStreamException()

시스템에서 제공되는 메시지로 설정된 메시지 문자열과 COR_E_ENDOFSTREAM으로 설정된 HRESULT를 사용하여 EndOfStreamException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the EndOfStreamException class with its message string set to a system-supplied message and its HRESULT set to COR_E_ENDOFSTREAM.

EndOfStreamException(SerializationInfo, StreamingContext) EndOfStreamException(SerializationInfo, StreamingContext) EndOfStreamException(SerializationInfo, StreamingContext) EndOfStreamException(SerializationInfo, StreamingContext)

지정한 serialization와 컨텍스트 정보를 사용하여 EndOfStreamException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the EndOfStreamException class with the specified serialization and context information.

EndOfStreamException(String) EndOfStreamException(String) EndOfStreamException(String) EndOfStreamException(String)

message로 설정된 메시지 문자열과 COR_E_ENDOFSTREAM으로 설정된 HRESULT를 사용하여 EndOfStreamException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the EndOfStreamException class with its message string set to message and its HRESULT set to COR_E_ENDOFSTREAM.

EndOfStreamException(String, Exception) EndOfStreamException(String, Exception) EndOfStreamException(String, Exception) EndOfStreamException(String, Exception)

지정된 오류 메시지와 해당 예외의 원인인 내부 예외에 대한 참조를 사용하여 EndOfStreamException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the EndOfStreamException class with a specified error message and a reference to the inner exception that is the cause of this exception.

속성

Data Data Data Data

예외에 대한 사용자 정의 추가 정보를 제공하는 키/값 쌍의 컬렉션을 가져옵니다.Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(Inherited from Exception)
HelpLink HelpLink HelpLink HelpLink

이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.Gets or sets a link to the help file associated with this exception.

(Inherited from Exception)
HResult HResult HResult HResult

특정 예외에 할당된 코드화된 숫자 값인 HRESULT를 가져오거나 설정합니다.Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(Inherited from Exception)
InnerException InnerException InnerException InnerException

현재 예외를 발생시킨 Exception 인스턴스를 가져옵니다.Gets the Exception instance that caused the current exception.

(Inherited from Exception)
Message Message Message Message

현재 예외를 설명하는 메시지를 가져옵니다.Gets a message that describes the current exception.

(Inherited from Exception)
Source Source Source Source

오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.Gets or sets the name of the application or the object that causes the error.

(Inherited from Exception)
StackTrace StackTrace StackTrace StackTrace

호출 스택의 직접 실행 프레임에 대한 문자열 표현을 가져옵니다.Gets a string representation of the immediate frames on the call stack.

(Inherited from Exception)
TargetSite TargetSite TargetSite TargetSite

현재 예외를 throw하는 메서드를 가져옵니다.Gets the method that throws the current exception.

(Inherited from Exception)

메서드

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetBaseException() GetBaseException() GetBaseException() GetBaseException()

파생 클래스에서 재정의되었을 때, 하나 이상의 후속 예외의 근본 원인이 되는 Exception을 반환합니다.When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(Inherited from Exception)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

파생 클래스에서 재정의될 때, 예외에 관한 정보를 SerializationInfo에 설정합니다.When overridden in a derived class, sets the SerializationInfo with information about the exception.

(Inherited from Exception)
GetType() GetType() GetType() GetType()

현재 인스턴스의 런타임 형식을 가져옵니다.Gets the runtime type of the current instance.

(Inherited from Exception)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

현재 예외에 대한 문자열 표현을 만들고 반환합니다.Creates and returns a string representation of the current exception.

(Inherited from Exception)

이벤트

SerializeObjectState SerializeObjectState SerializeObjectState SerializeObjectState

예외에 대한 serialize된 데이터가 들어 있는 예외 상태 개체가 만들어지도록 예외가 serialize될 때 발생합니다.Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(Inherited from Exception)

적용 대상

추가 정보