The FileOptions used for writing to the file
Syntax
Visual Basic (Declaration) | |
---|
Public Property FileOptions As FileOptions |
Example
Library/Library.Test/TestTransactedCompoundFile.cs
C# | Copy Code |
---|
using (TempFile temp = new TempFile())
using (TempFile temp2 = new TempFile())
{
byte[] sample = new byte[1024];
new Random().NextBytes(sample);
List<uint> handles = new List<uint>();
using (TransactedCompoundFile file = new TransactedCompoundFile(
new TransactedCompoundFile.Options(temp.TempPath) { FileOptions = FileOptions.WriteThrough }
))
{
for (int i = 0; i < 1000; i++)
{
var hid = file.Create();
handles.Add(hid);
file.Write(hid, sample, i, sample.Length - i);
}
file.Commit();
File.Copy(temp.TempPath, temp2.TempPath, true);
}
using (TransactedCompoundFile file = new TransactedCompoundFile(temp2.TempPath))
{
for (int i = 0; i < 1000; i++)
{
CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(handles[i])));
}
}
} |
VB.NET | Copy Code |
---|
Using temp As New TempFile()
Using temp2 As New TempFile()
Dim sample As Byte() = New Byte(1024) {}
New Random().NextBytes(sample)
Dim [handles] As New List(Of UInteger)()
Using file As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
Key .FileOptions = FileOptions.WriteThrough _
})
Dim i As Integer = 0
While i < 1000
Dim hid As var = file.Create()
[handles].Add(hid)
file.Write(hid, sample, i, sample.Length - i)
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
file.Commit()
File.Copy(temp.TempPath, temp2.TempPath, True)
End Using
Using file As New TransactedCompoundFile(temp2.TempPath)
Dim i As Integer = 0
While i < 1000
CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read([handles](i))))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
End Using
End Using
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also