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

Glossary Item Box

Creates a memory stream that uses 32k segments for storage

Syntax

Visual Basic (Declaration) 
Public Function New()
C# 
public SegmentedMemoryStream()

Example

Library/Library.Test/TestSegmentedStream.cs

C#Copy Code
using (SegmentedMemoryStream ms = new SegmentedMemoryStream())
{
    Assert.AreEqual(0L, ms.Length);
    Assert.AreEqual(0L, ms.Position);
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin));
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current));
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.End));

    ms.Position = 42L;
    Assert.AreEqual(42L, ms.Length);
    Assert.AreEqual(42L, ms.Position);
    Assert.AreEqual(42L, ms.Seek(42, System.IO.SeekOrigin.Begin));
    Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.Current));
    Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.End));

    ms.Position = 0;
    Assert.AreEqual(0L, ms.Position);
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin));
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current));
    Assert.AreEqual(0L, ms.Seek(-42, System.IO.SeekOrigin.End));
}
VB.NETCopy Code
Using ms As New SegmentedMemoryStream()
    Assert.AreEqual(0L, ms.Length)
    Assert.AreEqual(0L, ms.Position)
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin))
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current))
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.[End]))

    ms.Position = 42L
    Assert.AreEqual(42L, ms.Length)
    Assert.AreEqual(42L, ms.Position)
    Assert.AreEqual(42L, ms.Seek(42, System.IO.SeekOrigin.Begin))
    Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.Current))
    Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.[End]))

    ms.Position = 0
    Assert.AreEqual(0L, ms.Position)
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin))
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current))
    Assert.AreEqual(0L, ms.Seek(-42, System.IO.SeekOrigin.[End]))
End Using

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys