A compound file holds named byte streams in folder-like storages. List them from notes.cfb in the example ZIP.
dotnet add package RecursiveAI.OneArchiveRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using RecursiveAI.OneArchive; using RecursiveAI.OneArchive.Cfb; using var file = File.OpenRead("notes.cfb"); using var cfb = new CompoundFileReader(file); while (cfb.GetNextEntry() is { } entry) if (entry.Kind == ArchiveEntryKind.File) Console.WriteLine($"{entry.Name}: {entry.Size} bytes");
Paste the code above into Program.cs of a new dotnet new console project and dotnet run, or unzip the example and dotnet run.
Notes: 6 bytes Attachments/Chart: 4 bytes
The listing prints each stream’s path and byte count without copying its contents. Notes contains Draft followed by a newline; Attachments/Chart contains A,B followed by a newline. Open an intact file with a seekable stream, such as File.OpenRead; a malformed directory or sector chain can raise CompressionFormatException.
Variations
Show storages as well as streams. Remove the filter and print the entry kind:
using RecursiveAI.OneArchive.Cfb; using var file = File.OpenRead("notes.cfb"); using var cfb = new CompoundFileReader(file); while (cfb.GetNextEntry() is { } entry) Console.WriteLine($"{entry.Kind}: {entry.Name}");
File: Notes Directory: Attachments File: Attachments/Chart
Related recipes
The short answer
Open a seekable input with CompoundFileReader and call GetNextEntry() until it returns null. Keep entries with Kind == ArchiveEntryKind.File to list streams; drop the filter to see storages too. Use Name for the path from the root and Size for the number of bytes in the stream. This reads the container directory, not the application data inside each stream.
What is a compound file binary format stream?
A stream is a sequence of bytes with a name, like a file inside the container. A storage groups streams and other storages, like a folder. For example, in the supplied file Attachments is a storage; Attachments/Chart is a stream inside it. The reader presents them as Directory and File respectively. The root is available via Root and is not returned as a directory entry by GetNextEntry().
Some older Office documents, Outlook .msg files, and .msi installers use this layout. Recognizing the container is not the same as interpreting the document, message, or installer: OneArchive exposes the streams and their bytes, not a parsed view of the application format. The compound file docs describe the supported version 3 and 4 headers and directory structures. The CFB file signature is D0 CF 11 E0 A1 B1 1A E1; don’t assume a file is CFB just because its extension is .doc or .msg.
How do I list streams inside nested CFB storages?
Use the same loop for every depth. The reader visits each storage before its children and joins the components with /, so there’s no recursive traversal to implement. To distinguish two streams with the same leaf name in different storages, keep the full Name, not just the last component. The order follows the directory tree’s name order; sort your results separately if your UI needs a different order.
Name is a display path with special characters escaped; RawName is the original name of the individual entry. For instance, a summary stream whose stored name begins with the control character U+0005 appears as %0005SummaryInformation in the listing. The percent escape is part of the reader’s path representation, not part of the stored name. When calling the reader’s Find or OpenStream, use stored names as described in the name mapping docs, not the escaped display path.