Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
System.IO Namespace
Stream Class
 Stream Members

  Switch on low bandwidth view
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 FrameworkStream Initializes a new instance of the Stream class.
Top
  NameDescription
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkBeginRead Begins an asynchronous read operation.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkBeginWrite Begins an asynchronous write operation.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkClose Closes 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 FrameworkEndRead Waits for the pending asynchronous read to complete.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkEndWrite Ends an asynchronous write operation.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkEquals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkFinalize Allows 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 FrameworkFlush When 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 FrameworkGetHashCode Serves 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 FrameworkGetType Gets 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 FrameworkRead When 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 FrameworkReadByte Reads 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 FrameworkSeek When overridden in a derived class, sets the position within the current stream.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkSetLength When overridden in a derived class, sets the length of the current stream.
Public methodStatic memberSynchronized Creates a thread-safe (synchronized) wrapper around the specified Stream object.
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkToString Returns a String that represents the current Object. (Inherited from Object.)
Public methodSupported by the .NET Compact FrameworkSupported by the XNA FrameworkWrite When 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 FrameworkWriteByte Writes 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 FrameworkNull A Stream with no backing store.
Top
  NameDescription
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkCanRead When 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 FrameworkCanSeek When 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 FrameworkCanTimeout Gets a value that determines whether the current stream can time out.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkCanWrite When 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 FrameworkLength When overridden in a derived class, gets the length in bytes of the stream.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkPosition When overridden in a derived class, gets or sets the position within the current stream.
Public propertySupported by the .NET Compact FrameworkSupported by the XNA FrameworkReadTimeout Gets 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 FrameworkWriteTimeout Gets 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..::.Dispose For 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