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

filename
mode

Glossary Item Box

Creates an IFactory for creating streams on a single file

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal filename As String, _
   ByVal mode As FileMode _
)
C# 
public FileStreamFactory( 
   string filename,
   FileMode mode
)

Parameters

filename
mode

Example

Library/Library.Test/TestStreamCache.cs

C#Copy Code
Stream stream;
using (TempFile tempFile = new TempFile())
{
    using (StreamCache cache = new StreamCache(new FileStreamFactory(tempFile.TempPath, FileMode.Open)))
    {
        using (stream = cache.Open())
        {
            stream.SetLength(100);
            stream.WriteByte(1);
        }
    }

    Assert.AreEqual(100, tempFile.Length);
    using (stream = tempFile.Open())
        Assert.AreEqual(1, stream.ReadByte());
}
VB.NETCopy Code
Dim stream As Stream
Using tempFile As New TempFile()
    Using cache As New StreamCache(New FileStreamFactory(tempFile.TempPath, FileMode.Open))
        Using stream = cache.Open()
            stream.SetLength(100)
            stream.WriteByte(1)
        End Using
    End Using

    Assert.AreEqual(100, tempFile.Length)
    Using stream = tempFile.Open()
        Assert.AreEqual(1, stream.ReadByte())
    End Using
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