Export (0) Print
Expand All

SerialPort.BaseStream Property

Gets the underlying Stream object for a SerialPort object.

Namespace:  System.IO.Ports
Assembly:  System (in System.dll)

[BrowsableAttribute(false)]
public Stream BaseStream { get; }

Property Value

Type: System.IO.Stream
A Stream object.

ExceptionCondition
InvalidOperationException

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

NotSupportedException

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

BeginRead

BeginWrite

EndRead

EndWrite

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

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.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft