CfbReader

Overview

CfbReader is a low-level, read-only parser for Compound File Binary files. Construct it via FromFile or FromStream, then navigate the directory tree with IterStorages, IterStreams, IterChildren, and FindChildByName. Use GetStreamData to read raw bytes from a named stream. Implements IDisposable; always use it inside a using block to release file handles.

Constructors

SignatureDescription
CfbReader(data: byte[])Creates a new CfbReader with the specified parameters.

Methods

SignatureDescription
FromFile(path: string)Opens the CFB file at path and returns a new CfbReader.
FromStream(stream: Stream)Reads a CFB file from stream and returns a new CfbReader.
Dispose()Releases any file handle or stream held by this reader.
GetEntry(streamId: uint)Returns the DirectoryEntry for the given streamId.
GetStreamData(streamId: uint)Returns the raw byte content of the stream identified by streamId.
IterStorages()Yields all storage-type directory entries in tree order.
IterStreams()Yields all stream-type directory entries in tree order.
IterChildren(storageStreamId: uint)Yields direct child entries of the storage identified by storageStreamId.
IterTree(startStreamId: uint)Yields all entries in the subtree rooted at startStreamId (depth-first).
FindChildByName(storageStreamId: uint, name: string)Returns the stream ID of the direct child of storageStreamId whose name equals name, or null if not found.
ResolvePath(names: IEnumerable<string>, startStreamId: uint)Walks a sequence of names starting from startStreamId and returns the stream ID of the final entry.

Properties

NameTypeAccessDescription
HeaderHeaderReadThe parsed CFB file header; exposes sector-size fields.
DifatReadOnlyCollection<uint>ReadRead-only view of the DIFAT sector chain.
FatReadOnlyCollection<uint>ReadRead-only view of the FAT (file allocation table) sector chain.
MiniFatReadOnlyCollection<uint>ReadRead-only view of the FAT (file allocation table) sector chain.
DirectoryEntriesReadOnlyCollection<DirectoryEntry>ReadAll 128-byte directory entries parsed from the directory sectors, in raw order.
RootEntryDirectoryEntryReadThe root directory entry (stream ID 0).
MiniStreambyte[]ReadRaw bytes of the mini-stream container (the data stream of the root entry).
MajorVersionintReadCFB major version parsed from the file header.
SectorSizeintReadSector size in bytes (512 for v3, 4096 for v4).
MiniSectorSizeintReadSector size in bytes (512 for v3, 4096 for v4).
DirectoryEntryCountintReadTotal number of directory entry records in the directory sectors.
MaterializedStreamCountintReadNumber of streams with non-empty data in the parsed document.
FileSizeintReadTotal size of the source file or stream in bytes.

See Also