Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
System.IO Namespace
Stream Class
 Stream Members
Collapse All/Expand All Collapse All
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Stream Members

Provides a generic view of a sequence of bytes.

The Stream type exposes the following members.

  NameDescription
Protected methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkStreamCalled from constructors in derived classes to initialize the Stream class.
Top
  NameDescription
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkBeginReadBegins an asynchronous read operation.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkBeginWriteBegins an asynchronous write operation.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkCloseCloses the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Protected methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkCreateWaitHandle Obsolete. Allocates a WaitHandle object.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkDisposeOverloaded. Releases all resources used by the Stream object.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkEndReadWaits for the pending asynchronous read to complete.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkEndWriteEnds an asynchronous write operation.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkEqualsDetermines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkFinalizeAllows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkFlushWhen overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkMemberwiseCloneOverloaded.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkReadWhen overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkReadByteReads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkSeekWhen overridden in a derived class, sets the position within the current stream.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkSetLengthWhen overridden in a derived class, sets the length of the current stream.
Public methodStatic memberSynchronizedCreates a thread-safe (synchronized) wrapper around the specified Stream object.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkToStringReturns a String that represents the current Object. (Inherited from Object.)
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkWriteWhen overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkWriteByteWrites a byte to the current position in the stream and advances the position within the stream by one byte.
Top
  NameDescription
Public fieldStatic memberSupported by the .NET Compact FrameworkSupported by the XNA FrameworkNullA Stream with no backing store.
Top
  NameDescription
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkCanReadWhen overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkCanSeekWhen overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkCanTimeoutGets a value that determines whether the current stream can time out.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkCanWriteWhen overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkLengthWhen overridden in a derived class, gets the length in bytes of the stream.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkPositionWhen overridden in a derived class, gets or sets the position within the current stream.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkReadTimeoutGets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkWriteTimeoutGets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out.
Top
  NameDescription
Explicit interface implemetationPrivate methodSupported by the .NET Compact FrameworkIDisposable..::.DisposeFor a description of this member, see IDisposable..::.Dispose.
Top
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Suggestion      G1   |   Edit   |   Show History

1) Stream uses integer -1 as an end of stream indicator for the ReadByte() method. Consequently, this constant should exist somewhere in the library and ideally as a readonly field or property of stream itself. Consequently, the following becomes doable...

for (int b in myStream.ReadByte(); b != myStream.EndOfStream; b = myStream.ReadByte())

otherStream.WriteByte( (byte) b );

2) Another suggestion is to have inter-stream methods for the sake of completeness and intuitivity, as follows:

aStream.WriteAll( bStream );

and

aStream.ReadAll( bStream );

and

class Stream<T> : IEnumerable<T>

and

....

3) There is just such a lack of symmetry...thank goodness for extension methods....Sealed classes was definitely a mistake (sealed features if you must, but to seal the entire class is to kill the goose the lays the gold eggs).

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker