Bearbeiten

Freigeben über


SerialPort.BaseStream Property

Definition

Gets the underlying Stream object for a SerialPort object.

public:
 property System::IO::Stream ^ BaseStream { System::IO::Stream ^ get(); };
public System.IO.Stream BaseStream { get; }
[System.ComponentModel.Browsable(false)]
public System.IO.Stream BaseStream { get; }
member this.BaseStream : System.IO.Stream
[<System.ComponentModel.Browsable(false)>]
member this.BaseStream : System.IO.Stream
Public ReadOnly Property BaseStream As Stream

Property Value

A Stream object.

Attributes

Exceptions

The stream is closed. This can occur because the Open() method has not been called or the Close() method has been called.

The stream is in a .NET Compact Framework application and one of the following methods was called:

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)EndRead(IAsyncResult)EndWrite(IAsyncResult)

The .NET Compact Framework does not support the asynchronous model with base streams.

Remarks

Use this property for explicit asynchronous I/O operations or to pass the SerialPort object to a Stream wrapper class such as StreamWriter.

Any open serial port's BaseStream property returns an object that derives from the abstract Stream class, and implements read and write methods using the prototypes inherited from the Stream class: BeginRead, BeginWrite, Read, ReadByte, Write, and WriteByte. These methods can be useful when passing a wrapped serial resource to a Stream wrapper class.

Due to the inaccessibility of the wrapped file handle, the Length and Position properties are not supported, and the Seek and SetLength methods are not supported.

Applies to