---
Product: Aspose.Email
Platform: python
Page Type: reference
Canonical URL: https://reference.aspose.org/email/python/cfbreader
---

# CFBReader

## Overview

`CFBReader` is a class in Aspose.Email FOSS for Python.

Reusable reader for Compound File Binary (CFB) containers.

This class provides 11 methods for working with CFBReader objects in Python programs.
Available methods include: `__init__`, `close`, `find_child_by_name`, `from_file`, `get_entry`, `get_stream_data`, `iter_children`, `iter_storages`, `iter_streams`, `iter_tree`, `resolve_path`.
All public members are accessible to any Python application after installing the Aspose.Email FOSS for Python package.
Properties: `DIRECTORY_ENTRY_LAYOUT`, `HEADER_LAYOUT`, `data_size`, `difat`, `directory_entries`, `directory_entry_count`, and 12 more.

## Properties

| Name | Type | Access | Description |
|------|------|--------|-------------|
| `data_size` | `int` | Read | Gets the data size. |
| `major_version` | `int` | Read | Gets the major version. |
| `sector_size` | `int` | Read | Gets the sector size. |
| `mini_sector_size` | `int` | Read | Gets the mini sector size. |
| `fat_sector_count` | `int` | Read | Gets the fat sector count. |
| `directory_entry_count` | `int` | Read | Gets the directory entry count. |
| `materialized_stream_count` | `int` | Read | Gets the materialized stream count. |
| `file_size` | `int` | Read | Gets the file size. |
| `HEADER_LAYOUT` | `Dict[str, Tuple[int, int]]` | Read | Gets the header layout. |
| `DIRECTORY_ENTRY_LAYOUT` | `Dict[str, Tuple[int, int]]` | Read | Gets the directory entry layout. |
| `header` | `` | Read | Gets the header. |
| `difat` | `List[SectorNumber]` | Read | Gets the difat. |
| `fat` | `List[int]` | Read | Gets the fat. |
| `mini_fat` | `List[int]` | Read | Gets the mini fat. |
| `directory_entries` | `` | Read | Gets the directory entries. |
| `root_entry` | `` | Read | Gets the root entry. |
| `mini_stream` | `` | Read | Gets the mini stream. |
| `stream_data` | `Dict[StreamId, bytes]` | Read | Gets the stream data. |

## Methods

| Signature | Description |
|-----------|-------------|
| `__init__(data: bytes \| mmap.mmap, _mmap_owner: mmap.mmap \| None)` | Calls __init__(data, _mmap_owner) on this CFBReader instance. |
| `from_file(path: Path \| str)` → `"CFBReader"` | Loads a CFB file from the given path and returns a CFBReader instance |
| `close()` | Releases any resources associated with the opened CFB file |
| `get_entry(stream_id: StreamId)` → `DirectoryEntry` | Returns the DirectoryEntry for the specified stream identifier |
| `get_stream_data(stream_id: StreamId)` → `bytes` | Returns raw bytes of the stream identified by stream_id |
| `iter_storages()` → `Iterator[DirectoryEntry]` | Yields DirectoryEntry objects representing storage entries |
| `iter_streams()` → `Iterator[DirectoryEntry]` | Yields DirectoryEntry objects representing stream entries |
| `iter_children(storage_stream_id: StreamId)` → `Iterator[DirectoryEntry]` | Yields child DirectoryEntry objects of the given storage |
| `iter_tree(start_stream_id: StreamId)` → `Iterator[Tuple[int, DirectoryEntry]]` | Yield a depth-first tree traversal as `(depth, entry)` tuples. |
| `find_child_by_name(storage_stream_id: StreamId, name: str)` → `Optional[DirectoryEntry]` | Searches for a child entry with the given name under a storage |
| `resolve_path(names: Iterable[str], start_stream_id: StreamId)` → `Optional[DirectoryEntry]` | Resolve a storage/stream path by exact directory-entry names. |

## Examples

```python
from aspose.email_foss.cfb import CFBReader

with CFBReader.from_file("archive.cfb") as reader:
    print(f"sector_size={reader.sector_size}")
    for entry in reader.iter_storages():
        print(f"storage: {entry.name}")
    for entry in reader.iter_streams():
        data = reader.get_stream_data(entry.stream_id)
        print(f"stream: {entry.name}, {len(data)} bytes")
```

## See Also

- [Aspose.Email for Python — Enterprise API Reference](https://reference.aspose.com/email/python-net/)