Table of Contents

Method CanRead

Namespace
DocWright.Formats.Html
Assembly
DocWright.Formats.Html.dll

CanRead(Stream)

Sniffs whether a stream looks like HTML, restoring its position before returning.

public bool CanRead(Stream stream)

Parameters

stream Stream

The seekable stream to sniff.

Returns

bool

true when the stream looks like HTML.

Remarks

HTML has no magic number, so detection looks for a doctype or a recognizable element in the leading bytes. The probe is deliberately conservative: a false positive would let HTML claim a stream some other reader should have had, and this reader is registered after the ones that do have magic numbers precisely so that ordering, not this probe, is what keeps DOCX and DOC safe.

Exceptions

ArgumentNullException

stream is null.

ArgumentException

The stream is not seekable.