Completes the operation
            
            
            
Syntax
| Visual Basic (Declaration) |   | 
|---|
Sub Commit()   | 
 
            
            
             
            
						
            
            
            
            
Example
Library/Library.Test/TestFragmentedFile.cs
             | C# |  Copy Code | 
|---|
SharedMemoryStream shared = new SharedMemoryStream();
FragmentedFile.CreateNew(shared, 512, 100, 2).Dispose();
using (FragmentedFile ff = new FragmentedFile(shared, 512, 100, 2))
{
    long id;
    byte[] bytes = MakeBytes(255);
    using (Stream write = ff.Create(out id))
    using (ITransactable trans = (ITransactable)write)
    {
        write.Write(bytes, 0, bytes.Length);
        trans.Commit();
        Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)));
        trans.Rollback();
    }
    AssertThrows<InvalidDataException>(delegate() { ff.Open(id, FileAccess.Read); });
} | 
 
| VB.NET |  Copy Code | 
|---|
Dim [shared] As New SharedMemoryStream()
FragmentedFile.CreateNew([shared], 512, 100, 2).Dispose()
Using ff As New FragmentedFile([shared], 512, 100, 2)
    Dim id As Long
    Dim bytes As Byte() = MakeBytes(255)
    Using write As Stream = ff.Create(id)
        Using trans As ITransactable = DirectCast(write, ITransactable)
            write.Write(bytes, 0, bytes.Length)
            trans.Commit()
            Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)))
            trans.Rollback()
        End Using
    End Using
    AssertThrows(Of InvalidDataException)(Function() Do
        ff.Open(id, FileAccess.Read)
    End Function)
End Using | 
 
 
            
            
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
 
            
            
See Also