CSharpTest.Net
NonClosingStream Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : NonClosingStream Class

Glossary Item Box

Provides a stream wrapper that will not close/dispose the underlying stream

Syntax

Visual Basic (Declaration) 
Public Class NonClosingStream 
   Inherits AggregateStream
C# 
public class NonClosingStream : AggregateStream 

Example

Library/Library.Test/TestStreams.cs

C#Copy Code
MemoryStream ms = new MemoryStream(new byte[5]);
Assert.AreEqual(5, ms.Length);

using (Stream s = new NonClosingStream(ms))
    s.Close();

Assert.AreEqual(5, ms.Length);
Assert.AreEqual(0, ms.Position);
Assert.IsTrue(ms.CanRead);
Assert.AreEqual(5, ms.Read(new byte[10], 0, 10));
VB.NETCopy Code
Dim ms As New MemoryStream(New Byte(5) {})
Assert.AreEqual(5, ms.Length)

Using s As Stream = New NonClosingStream(ms)
    s.Close()
End Using

Assert.AreEqual(5, ms.Length)
Assert.AreEqual(0, ms.Position)
Assert.IsTrue(ms.CanRead)
Assert.AreEqual(5, ms.Read(New Byte(10) {}, 0, 10))

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.IO.Stream
         CSharpTest.Net.IO.AggregateStream
            CSharpTest.Net.IO.NonClosingStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys