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)

public Stream BaseStream { get; }
/** @property */
public Stream get_BaseStream ()

public function get BaseStream () : Stream

Not applicable.

Property Value

A Stream object.

Exception typeCondition

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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft