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

stream

Glossary Item Box

Creates a wrapper around the provided stream

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal stream As Stream _
)
C# 
public NonClosingStream( 
   Stream stream
)

Parameters

stream

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))

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys