CSharpTest.Net
CreateNew(String,Int32,Int32,Int32,FileOptions) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > CreateNew Method : CreateNew(String,Int32,Int32,Int32,FileOptions) Method

filename
blockSize
growthRate
cacheLimit
options

Glossary Item Box

Creates a new file (or truncates an existing one) that stores multiple smaller files

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function CreateNew( _
   ByVal filename As String, _
   ByVal blockSize As Integer, _
   ByVal growthRate As Integer, _
   ByVal cacheLimit As Integer, _
   ByVal options As FileOptions _
) As FragmentedFile
C# 
public static FragmentedFile CreateNew( 
   string filename,
   int blockSize,
   int growthRate,
   int cacheLimit,
   FileOptions options
)

Parameters

filename
blockSize
growthRate
cacheLimit
options

Example

Library/Library.Test/TestFragmentedFile.cs

C#Copy Code
long idFirst, idSecond, idThird;
using (TempFile file = new TempFile())
{
    if (true)
    {
        FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault);
        idFirst = ff.Create();
        idSecond = ff.Create();
        idThird = ff.Create();
        ff.Delete(idFirst);

        //Dangerous, only used for testing the case when ff was never disposed, nor GC'd
        GC.SuppressFinalize(ff);
        ff = null;
    }

    GC.Collect(0, GCCollectionMode.Forced);
    GC.WaitForPendingFinalizers();

    using (FragmentedFile f2 = new FragmentedFile(file.TempPath, 512))
    {
        Assert.IsTrue(f2.Create() < idSecond);
        Assert.IsTrue(f2.Create() > idThird);
    }
}
VB.NETCopy Code
Dim idFirst As Long, idSecond As Long, idThird As Long
Using file As New TempFile()
    If True Then
        Dim ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault)
        idFirst = ff.Create()
        idSecond = ff.Create()
        idThird = ff.Create()
        ff.Delete(idFirst)

        'Dangerous, only used for testing the case when ff was never disposed, nor GC'd
        GC.SuppressFinalize(ff)
        ff = Nothing
    End If

    GC.Collect(0, GCCollectionMode.Forced)
    GC.WaitForPendingFinalizers()

    Using f2 As New FragmentedFile(file.TempPath, 512)
        Assert.IsTrue(f2.Create() < idSecond)
        Assert.IsTrue(f2.Create() > idThird)
    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