---
title: FileExtensions
summary: API reference for FileExtensions.
status: draft
owner: saif-docgen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common
reference_type: package
---

# FileExtensions

Materializes a `Stream` into an in-memory byte array via `MemoryStream`. ([BR-089](../../business-rules.md#br-089-converting-a-stream-to-a-byte-array-copies-from-the-stream's-current-position---the-caller-owns-rewinding---and-does-not-dispose-the-source-stream))

## Purpose
- Materializes a `Stream` into an in-memory byte array via `MemoryStream`. ([BR-089](../../business-rules.md#br-089-converting-a-stream-to-a-byte-array-copies-from-the-stream's-current-position---the-caller-owns-rewinding---and-does-not-dispose-the-source-stream))

## Context
- Namespace: `SAIF.Common.Extensions`
- Assembly/package: `SAIF.Framework.Common`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| ToByteArray(this Stream stream) | `public static byte[] ToByteArray(this Stream stream)` | Copies the stream's contents into a `MemoryStream` and returns `ToArray()`; does not rewind or dispose the source stream. ([BR-089](../../business-rules.md#br-089-converting-a-stream-to-a-byte-array-copies-from-the-stream's-current-position---the-caller-owns-rewinding---and-does-not-dispose-the-source-stream)) |


## Sources
- `Common/SAIF.Common/Extensions/FileExtensions.cs`
