# OfficeImageFileWriter

Saves already encoded image bytes through a same-directory atomic file commit.

Class 

`OfficeIMO.Drawing`

**Namespace**

`OfficeIMO.Drawing`

**Assembly**

`OfficeIMO.Core`

**Source revision**

`b87f83792369` with working tree changes

**Source**

[OfficeImageFileWriter.cs:21](https://github.com/EvotecIT/OfficeIMO/blob/b87f837923696ed23fb7f1b4758e48121ac42a16/OfficeIMO.Core/Raster/OfficeImageFileWriter.cs#L21)

**Modifiers**

static

Saves already encoded image bytes through a same-directory atomic file commit.

## Inheritance

- object
- OfficeImageFileWriter

## Remarks

The supplied bytes are borrowed and are not modified, cloned, parsed, or format-validated. Keep them unchanged until the operation completes. An existing destination is overwritten only after staging succeeds. Unsupported atomic replacement fails without a non-atomic fallback. File-system failures propagate; failed staging is cleaned up when the file system permits it. Cancellation is observed while staging and immediately before commit. Once replacement begins, it can complete even if cancellation is requested. This API does not promise power-loss durability.

Filter members 

Show inherited

## Methods

`public static void WriteAllBytes(string path, byte[] encodedImage, CancellationToken cancellationToken = default)` [#](#method-writeallbytes-string-byte-threading-cancellationtoken)

[OfficeImageFileWriter.cs:21](https://github.com/EvotecIT/OfficeIMO/blob/b87f837923696ed23fb7f1b4758e48121ac42a16/OfficeIMO.Core/Raster/OfficeImageFileWriter.cs#L21)

Stages encoded bytes and atomically creates or replaces the destination file.

Parameters

**path string required**

The destination file path. Missing parent directories are created.

**encodedImage byte[] required**

Already encoded bytes, borrowed until the method returns.

**cancellationToken System.Threading.CancellationToken = default optional**

Cancels staging and prevents publication when observed before commit.

Exceptions

- `ArgumentNullException` – The supplied byte array is null.

`public static Task WriteAllBytesAsync(string path, byte[] encodedImage, CancellationToken cancellationToken = default)` [#](#method-writeallbytesasync-string-byte-threading-cancellationtoken)

[OfficeImageFileWriter.cs:39](https://github.com/EvotecIT/OfficeIMO/blob/b87f837923696ed23fb7f1b4758e48121ac42a16/OfficeIMO.Core/Raster/OfficeImageFileWriter.cs#L39)

Asynchronously stages encoded bytes and atomically creates or replaces the destination file.

Parameters

**path string required**

The destination file path. Missing parent directories are created.

**encodedImage byte[] required**

Already encoded bytes, borrowed until the returned task completes.

**cancellationToken System.Threading.CancellationToken = default optional**

Cancels staging and prevents publication when observed before commit.

Returns

`Task`

Exceptions

- `ArgumentNullException` – The supplied byte array is null.

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

<!-- PowerForge markdown artifact sha256:4FF39717D5403DA041245679D1526ABA00C486C44069FF5DFD4BD89A792487C3 -->
