Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Compound File .NET
>
Tutorial
> List storage (folder)
The following example shows you how to get storage and list its content.
C# example
using System; using Independentsoft.IO.StructuredStorage; namespace Sample { class Program { static void Main(string[] args) { CompoundFile file = new CompoundFile("c:\\temp\\test.bin"); //list root storage foreach (DirectoryEntry entry in file.Root.DirectoryEntries) { if (entry is Independentsoft.IO.StructuredStorage.Stream) { Console.WriteLine("Stream: " + entry.Name); } else { Console.WriteLine("Storage(Folder): " + entry.Name); } } Console.WriteLine("-----------------------------------------------"); //get storage and list content Independentsoft.IO.StructuredStorage.Storage storage = (Independentsoft.IO.StructuredStorage.Storage)file.Root.DirectoryEntries["myfolder"]; foreach (DirectoryEntry entry in storage.DirectoryEntries) { if (entry is Independentsoft.IO.StructuredStorage.Stream) { Console.WriteLine("Stream: " + entry.Name); } else { Console.WriteLine("Storage(Folder): " + entry.Name); } } Console.WriteLine("Press any key to exit!"); Console.Read(); } } }
VB example
Imports System Imports Independentsoft.IO.StructuredStorage Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim file As New CompoundFile("c:\temp\test.bin") 'list root storage For Each entry As DirectoryEntry In file.Root.DirectoryEntries If TypeOf entry Is Independentsoft.IO.StructuredStorage.Stream Then Console.WriteLine("Stream: " + entry.Name) Else Console.WriteLine("Storage(Folder): " + entry.Name) End If Next Console.WriteLine("-----------------------------------------------") 'get storage and list content Dim storage As Independentsoft.IO.StructuredStorage.Storage = DirectCast(file.Root.DirectoryEntries("myfolder"), Independentsoft.IO.StructuredStorage.Storage) For Each entry As DirectoryEntry In storage.DirectoryEntries If TypeOf entry Is Independentsoft.IO.StructuredStorage.Stream Then Console.WriteLine("Stream: " + entry.Name) Else Console.WriteLine("Storage(Folder): " + entry.Name) End If Next Console.WriteLine("Press any key to exit!") Console.Read() End Sub End Class End Namespace