Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Compound File .NET
>
Tutorial
> Create file
The following example shows you how to create simple compound file with two streams.
C# example
using System; using Independentsoft.IO.StructuredStorage; namespace Sample { class Program { static void Main(string[] args) { CompoundFile file = new CompoundFile(); byte[] descriptionBuffer = System.Text.UTF8Encoding.UTF8.GetBytes("File description"); byte[] dataBuffer = new byte[100000]; Independentsoft.IO.StructuredStorage.Stream descriptionStream = new Independentsoft.IO.StructuredStorage.Stream("description", descriptionBuffer); Independentsoft.IO.StructuredStorage.Stream dataStream = new Independentsoft.IO.StructuredStorage.Stream("data", dataBuffer); file.Root.DirectoryEntries.Add(descriptionStream); file.Root.DirectoryEntries.Add(dataStream); file.Save("c:\\temp\\file1.bin", true); } } }
VB example
Imports System Imports Independentsoft.IO.StructuredStorage Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim file As New CompoundFile() Dim descriptionBuffer As Byte() = System.Text.UTF8Encoding.UTF8.GetBytes("File description") Dim dataBuffer As Byte() = New Byte(99999) {} Dim descriptionStream As New Independentsoft.IO.StructuredStorage.Stream("description", descriptionBuffer) Dim dataStream As New Independentsoft.IO.StructuredStorage.Stream("data", dataBuffer) file.Root.DirectoryEntries.Add(descriptionStream) file.Root.DirectoryEntries.Add(dataStream) file.Save("c:\temp\file1.bin", True) End Sub End Class End Namespace