Table of Contents

CompoundStreamNotFoundException Class

Definition

Namespace
Bodu.IO.Compound
Assembly
Bodu.IO.Compound.dll
Package
Bodu.IO.Compound 1.0.0
Source
CompoundStreamNotFoundException.cs

The exception thrown when a named stream is requested from a compound file but no matching directory entry exists.

public sealed class CompoundStreamNotFoundException : CompoundFileException, ISerializable
Inheritance
CompoundStreamNotFoundException
Implements
Inherited Members
Extension Methods

Examples

Catch the exception when a stream is expected to exist, or switch to the Try pattern when its absence is a normal outcome:

try
{
    CompoundStream entry = file.RootStorage.OpenStream("Workbook");
}
catch (CompoundStreamNotFoundException ex)
{
    Console.WriteLine($"Missing stream: {ex.StreamName}");
}

// Non-throwing alternative:
if (file.RootStorage.TryOpenStream("Workbook", out CompoundStream? workbook))
{
    // ...
}

Remarks

Thrown by OpenStream(string) and OpenStorage(string). Callers that prefer a non-throwing lookup should use TryOpenStream(string, out CompoundStream) or TryOpenStorage(string, out CompoundStorage) instead. It derives from CompoundFileException, the common base for all compound-file failures.

Constructors

CompoundStreamNotFoundException()

Initializes a new instance of the CompoundStreamNotFoundException class.

public CompoundStreamNotFoundException()

CompoundStreamNotFoundException(string)

Initializes a new instance of the CompoundStreamNotFoundException class with the specified message.

public CompoundStreamNotFoundException(string message)

Parameters

message string

A message that describes the lookup failure.

CompoundStreamNotFoundException(string, Exception)

Initializes a new instance of the CompoundStreamNotFoundException class with the specified message and a reference to the underlying cause.

public CompoundStreamNotFoundException(string message, Exception innerException)

Parameters

message string

A message that describes the lookup failure.

innerException Exception

The exception that is the cause of this exception.

Properties

StreamName

Gets the name of the stream that was requested but not found, when known.

public string? StreamName { get; }

Property Value

string

The requested stream name, or null when this instance was created without one.

Applies to

ProductVersions
.NET8, 10