Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

OfficeImageFileWriter

OfficeIMO.Drawing

Namespace
OfficeIMO.Drawing
Assembly
OfficeIMO.Core
Source revision
b87f83792369 with working tree changes
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.

Methods

public static void WriteAllBytes(string path, byte[] encodedImage, CancellationToken cancellationToken = default) #

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) #

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.