Method CanRead
CanRead(Stream)
Always returns false: plain text is never auto-detected.
public bool CanRead(Stream stream)
Parameters
streamStreamThe seekable stream, examined only to validate the argument.
Returns
Remarks
This is a deliberate refusal, not an omission, and it is the one place this package departs from the phase's exit criteria — so it is stated here rather than left to be discovered.
Every byte sequence is valid plain text. A sniff that returned true for anything
decodable would claim every stream no other reader recognized: a truncated DOCX, a
corrupt .doc, a PNG someone renamed. The caller would get a document full of
mojibake instead of the InvalidDocumentException that tells them what actually
happened, and no amount of heuristic tuning fixes that, because the heuristic would be
deciding a question the bytes do not answer.
Plain text is therefore reached explicitly: by the .txt or .text
extension, which the registry resolves without consulting this method, or by passing
FormatDetection.Text. Both are tested.
Exceptions
- ArgumentNullException
streamis null.- ArgumentException
The stream is not seekable.