Visual Basic (Declaration) | |
---|---|
Public Function New( _ ByVal rawStream As Stream, _ ByVal start As Long, _ ByVal length As Long _ ) |
Parameters
- rawStream
- The stream to use for read/write
- start
- The position in the stream that should start the range of allowed bytes
- length
- The maximum length that can be read from the stream
Library/Library.Test/TestClampedStream.cs
C# | Copy Code |
---|---|
using (MemoryStream ms = new MemoryStream(SequencedBytes(20))) using (Stream s = new ClampedStream(ms, 10, 5)) { byte[] test = new byte[200]; Assert.AreEqual(5, s.Read(test, 0, 200)); Array.Resize(ref test, 5); Assert.AreEqual(new byte[] { 10, 11, 12, 13, 14 }, test); s.Position = 0; s.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5); s.Position = 0; Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5 }, IOStream.ReadAllBytes(s)); } |
VB.NET | Copy Code |
---|---|
Using ms As New MemoryStream(SequencedBytes(20)) Using s As Stream = New ClampedStream(ms, 10, 5) Dim test As Byte() = New Byte(200) {} Assert.AreEqual(5, s.Read(test, 0, 200)) Array.Resize(test, 5) Assert.AreEqual(New Byte() {10, 11, 12, 13, 14}, test) s.Position = 0 s.Write(New Byte() {1, 2, 3, 4, 5}, 0, 5) s.Position = 0 Assert.AreEqual(New Byte() {1, 2, 3, 4, 5}, IOStream.ReadAllBytes(s)) End Using End Using |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
ClampedStream ClassClampedStream Members
Overload List